Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > datagrid check
 

datagrid check

hi,

i have a datagridview havingtwo column in which one is checckbox column.at run time now more than 100 values will fill.And now i want to check each of them.What i want is to put a checkbox below datagrid in name check all and while checking that entire column should checked and while uncheck entire column should uncheck.How can i do this is there any property in datagrid

elby
  • Moved byeryangMSFTMonday, September 07, 2009 10:03 AM (From:.NET Base Class Library)
  •  
Elby Paul  Saturday, September 05, 2009 8:58 AM
Hi,
I hope it will help you

  private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            CheckUncheckDGV(checkBox1.Checked);
        }
        private void CheckUncheckDGV(bool state)
        {
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                dataGridView1.Rows[i].Cells[0].Value = state;
                dataGridView1.Rows[i].Cells[1].Value = state;
            }
        }

Best Regards, C.Gnanadurai ----------------------- Please mark the post as answer if it is helpfull to you
Gnanadurai  Saturday, September 05, 2009 9:24 AM
Hi,
I hope it will help you

  private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            CheckUncheckDGV(checkBox1.Checked);
        }
        private void CheckUncheckDGV(bool state)
        {
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                dataGridView1.Rows[i].Cells[0].Value = state;
                dataGridView1.Rows[i].Cells[1].Value = state;
            }
        }

Best Regards, C.Gnanadurai ----------------------- Please mark the post as answer if it is helpfull to you
Gnanadurai  Saturday, September 05, 2009 9:24 AM

You can use google to search for other answers

Custom Search

More Threads

• Binding to static dropdownlist
• Combo Box - Newbie Question
• Update DataGridView hidden colums with BindingNavigatorSaveItem event
• DataGrid Setting column widths
• DataGridView, Visual C++, Adding rows
• Styling the Checkbox in the DataGridViewCheckBox column.
• Using DataGridView for displaying large files with filter ability
• datagrid open with a new record
• Filtering on a combobox
• Remove Rows in DataTable and how to print distinct field name?