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.
Unfortunately, activation email could not send to your email. Please try again.

Reg: GridControl

Thread ID:

Created:

Updated:

Platform:

Replies:

32684 Aug 5,2005 10:21 AM Aug 6,2005 12:17 PM Windows Forms 6
loading
Tags: GridControl
Anna Srinivasan
Asked On August 5, 2005 10:21 AM

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 10:38 AM

>>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 01:26 AM

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 06:16 AM

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 08:36 AM

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 11:34 AM

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 12:17 PM

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;

CONFIRMATION

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.

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.

;