Set checked state on all selected rows in datagridview
-
I'm struggling to get this to work.. Is it possible to set the checked state on all the selected rows in an datagridview at the same time (e.g. when the user selects multiple rows using ctrl+mouseclick)? Any help would be appreciated :-D
hakonvik wrote:
I'm struggling to get this to work.. Is it possible to set the checked state on all the selected rows in an datagridview at the same time (e.g. when the user selects multiple rows using ctrl+mouseclick)?
From reading the manual, I've come up with a minimal idea. To set checked on all rows selected, you would iterate over all the rows of your data source, and for each row check IsSelected, and if it is, set the appropriate checked value in the data source. Then you'd have to get the data grid to update its display for the new values. Nathan
-
hakonvik wrote:
I'm struggling to get this to work.. Is it possible to set the checked state on all the selected rows in an datagridview at the same time (e.g. when the user selects multiple rows using ctrl+mouseclick)?
From reading the manual, I've come up with a minimal idea. To set checked on all rows selected, you would iterate over all the rows of your data source, and for each row check IsSelected, and if it is, set the appropriate checked value in the data source. Then you'd have to get the data grid to update its display for the new values. Nathan
Well, yes that is right but not quite my problem. My datagrid has an checkbox on each row in the first cell (built in code). The problem occurs when I have selected multiple rows and click one of the checkbox cells (in which case I want all the selected to get checked :-)) I can check selected rows by putting a button or link outside the grid, but that is not "normal" windows behaviour.. Any ideas:confused: