We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Reg: GridControl

hi, I am using grid control in my app. In the control first column is checkbox. REq: I have to delete all the checked rows. For deletion i am using context menu. check the column and do delete operation(right click and select delete in the grid except corresponding check cell) deletion is happenning. But check the column and right click in the same cell and then select delete operation deletion is not happenning(checked cell changed into unchecked cell that all). Note :sfgRedempSchedule = Grid Control Delete Code: for (int i = 1; i <= this.sfgRedempSchedule.RowCount; i++) { if (Convert.ToBoolean(this.sfgRedempSchedule[i, 1].CellValue)) { sfgRedempSchedule.Rows.RemoveRange(i,i); } } CheckBox Settings: sfgRedempSchedule[row, 1].CellType = chkCellType; sfgRedempSchedule[row, 1].CheckBoxOptions = new GridCheckBoxCellInfo(true.ToString(), false.ToString(), "", true); sfgRedempSchedule[row, 1].CellValueType = typeof(bool); sfgRedempSchedule[row, 1].CellValue = false; Context menu code: private void redempMenu_Popup(object sender, System.EventArgs e) { int delCount = 0; for (int ctr=1; ctr < sfgRedempSchedule.RowCount+1; ctr++) { if (Convert.ToBoolean(this.sfgRedempSchedule[ctr, 1].CellValue)) { delCount++; } } if (this.NonCgcAsset) { if (delCount > 0) { this.miDelete.Enabled = true; } else { this.miDelete.Enabled = false; } } else { this.miAdd.Enabled = false; this.miDelete.Enabled = false; } } Thanks, Anna

6 Replies

AD Administrator Syncfusion Team August 5, 2005 02:38 PM UTC

>>for (int i = 1; i <= this.sfgRedempSchedule.RowCount; i++) { if (Convert.ToBoolean(this.sfgRedempSchedule[i, 1].CellValue)) { sfgRedempSchedule.Rows.RemoveRange(i,i); } } I think the problem is in this code. Say row 1 and 2 are checked and need to be deleted. Your code checks row 1 and deletes row 1 and then increments i. But what happens when you delete row 1. The row that was in 2 now is row 1. So, when your code checks for i = 2, it is really checking what was originally row 3, and the original row 2 is not checked at all as it is being skipped. This is coding problem. There are several ways to work around it, but I would first just try running the loop in reverse order.


AS Anna Srinivasan August 6, 2005 05:26 AM UTC

Hi, I think u dint get my problem. Deletion is working....! Problem is If i click the check box and the same check box cell do right click and perform delete operation. This time deletion is not happenning. Other then check box cell deletion is happenning. Thanks, Anna


AD Administrator Syncfusion Team August 6, 2005 10:16 AM UTC

Just something to try. Before doing your delete code, try calling grid.CurrentCell.MoveTo(-1, -1). If that does not work for you, uplad a sample project showing the problem and we can try to suggest a resolution.


AS Anna Srinivasan August 6, 2005 12:36 PM UTC

Hi, I need deletion and addition functionality. Sample:.. delete_1338.zip Note: Roght click on the checkbox cell and perform delete operation.


AD Administrator Syncfusion Team August 6, 2005 03:34 PM UTC

Here is your sample back. I added numbers in the rows so you can see what rows are deleted. I then reversed the order of the loop as i suggested above. The deletes seem to work for me when this is done. Did it not work when you tried it? http://www.syncfusion.com/Support/user/uploads/WindowsApplication1_f7040cd1.zip


AD Administrator Syncfusion Team August 6, 2005 04:17 PM UTC

Are you talking about right-click affecting the value of the current checkbox? If so, try setting tihs property in form.load. this.sfgRedempSchedule.Model.Options.SelectCellsMouseButtonsMask = MouseButtons.Left;

Loader.
Live Chat Icon For mobile
Up arrow icon