Windows Develop Bookmark and Share   
 index > Windows Forms Sample Applications > delete more than one row in datagridview using checkboxes
 

delete more than one row in datagridview using checkboxes

I populated datagridview with data. one column is checkbox for selecting row,another is a textbox column and finally a combobox
when i am trying to delete more than one row by checking checkbox using the following code, it is not recognizing the row that is checked,nothing is happening.In the delete button click ,i wrote the following code

if (dataGridView2.SelectedRows.Count==dataGridView2.Rows.Count)
{
dataGridView2.Rows.Clear();
}

foreach (DataGridViewRow row in dataGridView2.SelectedRows)
{
dataGridView2.Rows.Remove(row);

Any help please....
usha.talasila  Tuesday, July 07, 2009 1:31 PM
Hello usha,

DataGridView.SelectedRows :
Gets the collection of rows selected by the user.
And not the rows which are checked(by using checkboxcolumn)by user.

On DeleteButton you have to loop through all rows and check the value of that checkBoxColumn
and then remove it.
NareshG  Wednesday, July 08, 2009 6:33 AM
Hello usha,

DataGridView.SelectedRows :
Gets the collection of rows selected by the user.
And not the rows which are checked(by using checkboxcolumn)by user.

On DeleteButton you have to loop through all rows and check the value of that checkBoxColumn
and then remove it.
NareshG  Wednesday, July 08, 2009 6:33 AM
Thanks Naresh i got it
usha.talasila  Friday, July 10, 2009 4:58 PM

You can use google to search for other answers

Custom Search

More Threads

• ExpandableList Paint Bug
• PocketVision - References problem
• One question about Authentication XML Web Service!!
• I use the print class of FotoVision to make a image print program, why doesn't it work?
• Edit Masked TextBox in c#
• How can I run TaskVision on my computer when it is disconected Internet?
• Login (Windows Application)...
• Terrarium Status -- Contest, Framework 1.1
• Attacking by herbies...
• Movie Collection Kit - Need Help