I have a GDBG bound to a datasource. One of the columns is a boolean. One and only one of the rows can be checked. Currently I''m planning to implement it by making that column a Checkbox column. When they check one, I''ll uncheck all the others. If they try to uncheck the checked one, I will prevent it.
1) Is this the best approach? The functionality I''m describing is that of Radio Buttons. Can I make a Radio Button column so that one and only one row can be checked?
2) What event do I handle that will be fired when the CheckedChanged event of a CheckBox is fired?
3) In that event, how can I loop though all the other rows (excluding the one the checkbox that fired the event is on) and make sure none of them have that column checked (if the new state of the current row''s checkbox is "Checked")?
ADAdministrator Syncfusion Team June 15, 2004 01:33 PM
I think you can use CheckBoxClick to handle this. Here is a try at it.
LPLee PerkinsJune 16, 2004 05:07 AM
Thank for the example! I have a couple of questions. In the CheckBoxClick event, how can I tell what the state of the clicked checkbox is? (Will it already have the new state at this point, or is this event fired BEFORE the state changes?) How can I access the data in the rest of the row the clicked checkbox is in? And last (but not least :) ), how can I loop through the rows of the datagrid accessing the data in the columns?
I''d rather not keep track of a row index that is currently checked. When they check a row, I want to actually look for the previously checked row (because when the grid first displays, there might not be a checked row) and uncheck it.
I guess I''m mainly confused at this point about how to access the data through the grid. I can access the data in the datasource (a custom collection), but if I have a row in my datasource, how do I access that row in the grid? How do I convert between a row index in my datasource and a row index in the grid? If I have a row index in the grid, how do I access that row in the grid and get the column data for that row?
Ok, 20 Questions is over (for now). :)
ADAdministrator Syncfusion Team June 16, 2004 06:08 AM
You can access any value in the grid by using an indexer, grid[row, col].CellValue (or in VB, grid(row, col).CellValue).
LPLee PerkinsJune 16, 2004 06:17 AM
Thanks. That''s easier to type than grid.Model(RowIndex, ColIndex).CellValue. :)