DataGriview issue PLease help!
I have a datagridview on a windows form and I need to select all the rows in the gridview when the user clicks a check box on the form.
I put the code in the the Form_Load event handler:
Code:
if (ckSelAll.Checked == true)
{
foreach (DataGridViewRow dgrv in MyGridView.Rows)
{
dgrv.Selected = true;
}
}
when I load the form and check the checkbox, nothing happens.
Please help. Thanks.
Re: DataGriview issue PLease help!
create a new button, add this code to the button, check a value and then click on the button then it will work.
it doesn't work right now because you have it on form load... but when the form loads no one of the values is checked.
Re: DataGriview issue PLease help!
I can't remember if there is a property for this, but make sure you can select multiple rows. The datagridview could be set so that only one row can be selected at a time.
Re: DataGriview issue PLease help!
Code:
if (ckSelAll.Checked == true)
{
foreach (DataGridViewRow dgrv in MyGridView.Rows)
{
dgrv.Selected = true;
}
}
You simple need to put this code into the buttons Click delegate