public void Filter() { Form frm = this.Parent.FindForm().GetType().Name == "frmMain" ? this.Parent.FindForm().ActiveMdiChild : this.Parent.FindForm(); // Tim form tren tabcontrol if (frm == null) { frm = Common.FindFormChildInTab(); } if (frm == null) { return; } object ExportControl = ((frmBase)frm).ExportControl; if (ExportControl == null) { return; } //dgvControl if (Common.Inlist(ExportControl.GetType().Name, "dgvControl,dgvReport,dgvVoucher")) { dgvControl dgv = (dgvControl)ExportControl; if (strColumnFilter == string.Empty) { strColumnFilter = dgv.CurrentCell.OwningColumn.DataPropertyName; } if (dgv.bdsFind == null) //|| this.CurrentCell == null) { return; } if (dgv.bFilter == false) { dgv.strFilterOrg = dgv.bdsFind.Filter; } string strFilter = "(" + strColumnFilter + " LIKE '%" + this.Text + "%')"; if (((DataTable)dgv.bdsFind.DataSource).Columns[strColumnFilter].DataType.Name != "String") { return; } if (dgv.strFilterOrg != string.Empty && dgv.strFilterOrg != null) { dgv.bdsFind.Filter = "(" + dgv.strFilterOrg + ") AND " + strFilter; } else { dgv.bdsFind.Filter = strFilter; } if (dgv.Rows.Count > 0) { dgv.CurrentCell = dgv.Rows[0].Cells[strColumnFilter]; } dgv.bFilter = true; } else if (Common.Inlist(ExportControl.GetType().Name, "tlControl,tlReport")) { tlControl tl = (tlControl)ExportControl; //if (tl.FocusedColumn == null) // return; if (strColumnFilter == string.Empty) { strColumnFilter = tl.FocusedColumn.FieldName; } if (tl.bdsFind == null) { return; } if (tl.bFilter == false) { tl.strFilterOrg = tl.bdsFind.Filter; } string strFilter = strColumnFilter + " LIKE '%" + this.Text + "%'"; //bdsFind.Filter = strFilter; if (tl.strFilterOrg != string.Empty && tl.strFilterOrg != null) { tl.bdsFind.Filter = "(" + tl.strFilterOrg + ") AND " + strFilter; } else { tl.bdsFind.Filter = strFilter; } if (tl.Nodes.Count > 0) { tl.SetNodeIndex(tl.Nodes[0], tl.Columns[strColumnFilter].VisibleIndex); } tl.bFilter = true; } }