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.

Problems with unbound checkbox column

Thread ID:

Created:

Updated:

Platform:

Replies:

44603 May 29,2006 11:50 AM May 30,2006 09:35 AM Windows Forms 4
loading
Tags: GridControl
Alex
Asked On May 29, 2006 11:50 AM

Hi, i am using the GDBG with columns bound to a data set and an additional unbound checkbox column. To get along with the unbound column I used the example from the Knowledgebase. What I tried to accomplish additionally is to throw an event every time a checkbox state changes and be able to get all checked rows in the grid afterwards. My first problem is that the display of the checkbox gets messed up, as soon as I modify Model_SaveCellInfo() to execute some additional code which basically gets all selected rows in the grid. Additionally, the additional code seems to stop executing (I can''t step forward with the debugger) for reasons I do not know. I expect this to be a timing problem maybe linked to the QueryCellInfo event but I can''t really say. Maybe you can help me with my problem? Regards, Alex

Administrator [Syncfusion]
Replied On May 30, 2006 12:29 AM

Hi Alexander, Try this code to get all checked checkbox record in a grid using CurrentCellChanged event. Here is a code snippet in C#.Net. private void gridDataBoundGrid1_CurrentCellChanged(object sender, System.EventArgs e) { Console.WriteLine("Checked CheckBox Details....."); GridDataBoundGrid grid = sender as GridDataBoundGrid; GridCurrentCell cc = grid.CurrentCell as GridCurrentCell; int ColIndex = grid.Binder.NameToColIndex("CheckBox"); for(int i = 1 ;i< grid.Model.RowCount;i++) { object obj = grid.Model[i, ColIndex].CellValue; if(obj != null && obj.ToString() != string.Empty && obj.ToString() == "True") Console.WriteLine(" Check CheckBox RowIndex :" + i + " Products CellValue -> " + grid.Model[i, 1].CellValue); } } Here is a sample. http://www.syncfusion.com/Support/user/uploads/UnboundCheckBoxColumn_CS_ecb46030.zip Let me know if you need any further assistance. Regards, Haneef

Alex
Replied On May 30, 2006 02:00 AM

Hi Haneef, thank you very much! The code works perfectly :-) Regards, Alexander

Alex
Replied On May 30, 2006 08:23 AM

Hi Haneef, Unfortunately, my last post came a bit early altough it seemed my problem was solved by the solution you provided. Basically, the timing problem still exists but with your suggested code in the CurrentCellChanged event handler the time frame for my own code to execute has extended. The more operations are executed in the event handler, the higher is the possibilty that the code stops executing randomly. Regards, Alex

Administrator [Syncfusion]
Replied On May 30, 2006 09:35 AM

Hi Alex, You need to store the checked checkbox record into ArrayList in a grid''s Model_SaveCellInfo event and retrive this information from any event(currentCellchanged Event). Here is a code snippet in C# ArrayList checkedlist = new ArrayList(); private void Model_SaveCellInfo(object sender, GridSaveCellInfoEventArgs e) { GridModel model = this.gridDataBoundGrid1.Model; int ColIndex = this.gridDataBoundGrid1.Model.NameToColIndex("CheckBox"); if(e.RowIndex > 0 && e.ColIndex == ColIndex) { int keyColIndex = model.NameToColIndex("Product_ID"); string key = model[e.RowIndex, keyColIndex].Text; if (key != null) { CheckBoxValues[key] = e.Style.CellValue; if(checkedlist.Contains(key) ) { if(! (e.Style.CellValue.ToString() == "True" ) ) checkedlist.Remove(key); } else checkedlist.Add(key); } } } } //Get the infomation from Button click/any event you want. Console.WriteLine("Checked CheckBox Details....."); for(int i = 0 ; i< checkedlist.Count ;i++) { Console.WriteLine(checkedlist[i]); } Here is a sample. http://www.syncfusion.com/Support/user/uploads/UnboundCheckBoxColumn_CS_fe25efea.zip Let me know if you need any further assistance. Regards, Haneef

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.

;