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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Reg: GridControl

Thread ID:





32684 Aug 5,2005 02:21 PM UTC Aug 6,2005 04:17 PM UTC WinForms 6
Tags: GridControl
Anna Srinivasan
Asked On August 5, 2005 02:21 PM UTC

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

Administrator [Syncfusion]
Replied On 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.

Anna Srinivasan
Replied On 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

Administrator [Syncfusion]
Replied On 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.

Anna Srinivasan
Replied On 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.

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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;


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon