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

Problem with Check box handling : GridDataBoundGrid

Hi, I am trying to set the grid style using following code: gridAlarmDetails.Binder.InternalColumns[Index].StyleInfo.CellType = "CheckBox"; gridAlarmDetails.Binder.InternalColumns[Index].StyleInfo.CellValueType = typeof(bool); gridAlarmDetails.Binder.InternalColumns[Index].StyleInfo.CellValue = false; I gives a error, "index out of range". I tried giving string (Column name) instead of Index, i do not give any error but changes are not reflected. Same code is working fine in another Form. Only different between the two form is that in working form grid is directly added to Form while in non-working code grid is added in Tab-page which is added to form. Thanks, Supriya Grid_1712.zip

3 Replies

AD Administrator Syncfusion Team April 5, 2004 07:19 AM

Hi Supriya, I saw those two files, i guess you are having trouble in this AlarmsManagerUI-InsideTab.cs. In that i see you are trying to set the check box styles using this code instead of the above posted code. gridAlarmDetails.Model.ColStyles[ColName].CellType = "CheckBox"; gridAlarmDetails.Model.ColStyles[ColName].CellValueType = typeof(bool); gridAlarmDetails.Model.ColStyles[ColName].CellValue = false; Instead of this try setting the properties by accessing the styleinfo properties through binder and set the checkboxoptions property to see if that helps. gridAlarmDetails.Binder.InternalColumns[Index].CheckBoxOptions = new Syncfusion.Windows.Forms.Grid.GridCheckBoxCellInfo(true.ToString(), false.ToString(), "", true); Also what version of the grid are you using? Regards, Jay N


RA Rajiv April 5, 2004 09:00 PM

Hi Jay, We tried seting the properties using the binder but i was giving ''Invalid Index Error'' so we tried other ways. Same code works fine if i remove tab control and add grid control directly to Form. Thanks and Regards, Rajiv >Hi Supriya, >I saw those two files, i guess you are having trouble in this AlarmsManagerUI-InsideTab.cs. In that i see you are trying to set the check box styles using this code instead of the above posted code. > > >gridAlarmDetails.Model.ColStyles[ColName].CellType = "CheckBox"; >gridAlarmDetails.Model.ColStyles[ColName].CellValueType = typeof(bool); >gridAlarmDetails.Model.ColStyles[ColName].CellValue = false; > > >Instead of this try setting the properties by accessing the styleinfo properties through binder and set the checkboxoptions property to see if that helps. > >gridAlarmDetails.Binder.InternalColumns[Index].CheckBoxOptions = new Syncfusion.Windows.Forms.Grid.GridCheckBoxCellInfo(true.ToString(), false.ToString(), "", true); > > >Also what version of the grid are you using? > >Regards, >Jay N


AD Administrator Syncfusion Team April 6, 2004 07:12 AM

Hi Rajiv, I suspect it is because at that time when you try to assign the styleinfo properties, the grid was not initialized yet and therefore there are no InternalColumns and that’s why there is an exception being thrown. Try checking the InternalColumns.Count at the moment when you try to access it. Is it possible to move that code out of the form''s constructor to the Form_Load event handler. Then there is a better chance that the control has been fully created and its BindingContext initialized. Attached is a sample that has a GDBG in a tabpage with a checkbox column. Thanks, Jay N forum_checkbox.zip

Loader.
Live Chat Icon For mobile
Up arrow icon