Closed farshadvl closed 1 year ago
Hello, I don't fully understaind how you would like the grid to perform. If you are working on the FilterStringChanged Event you should edit the Event arg, not forcing the Row Cells on the grid.
Something like so, but I've not your datasource and so on, so you have to test it
private void DG_AllMatRequest_FilterStringChanged(object sender, Zuby.ADGV.AdvancedDataGridView.FilterEventArgs e)
{
e.FilterString += (!String.IsNullOrEmpty(e.FilterString) ? " AND " : "") + String.Format("Remain_Qty != 0", textBox_filterPatient.Text.Replace("'", "''"));
}
Also to colorize the column It's better to attach a CellFormatting event, something like show here: https://stackoverflow.com/questions/19380279/changing-datagridview-cell-color-based-on-condition
Hi Man . tnx for response but I haven't seen it until today. I think if you see the screen shot you can understand better. I have a datagridview in my form , load datat from sql to it and with checking ruls I show/hide first column in this datagridview checkboxs. when in this dgv I don't filter data check box cells are ok but If I filter some columns in this dgv the Rules broken and it shows the checkbox. please see this images: https://uplod.ir/aggzrfraympt/1.PNG.htm https://uplod.ir/lwicv5mxli1o/2.PNG.htm
``Hi man I have a for with ADGV to show data from db in it. In my db I have a column(Remain_QTY) that calculated from rows in sql and show number like 0,1,2. I want to disable rows Remain_QTY that has 0 in it. I have written this code and it works when data fetch first-time from db but after I filter data in ADGVit doesn't work. see my code plz:
private void DisableZeroQty() { if (DG_AllMatRequest.Rows.Count > 0) { for (int i = 0; i < DG_AllMatRequest.Rows.Count; i++) { decimal.TryParse(DG_AllMatRequest.Rows[i].Cells["Remain_Qty"].Value.ToString(), out decimal _remain); if (_remain == 0) { DataGridViewTextBoxCell cell = new(); cell.Value = ""; DG_AllMatRequest.Rows[i].Cells[0] = cell; DG_AllMatRequest.Rows[i].Cells[0].ReadOnly = true; DG_AllMatRequest.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.Khaki;
private void DG_AllMatRequest_FilterStringChanged(object sender, Zuby.ADGV.AdvancedDataGridView.FilterEventArgs e) { DisableZeroQty(); }