Home / Community & Support / Knowledge Base / RadControls for WinForms / GridView / Selecting rows using unbound GridViewCheckBoxColumn

Selecting rows using unbound GridViewCheckBoxColumn

Article Info

Rating: 1

Article information

Article relates to

RadGridView for WinForms

Created by

Georgi Stoyanov, Telerik

Last modified

July 29, 2008

Last modified by

Georgi Stoyanov, Telerik


 
HOW-TO
Select rows using unbound GridViewCheckBoxColumn

SOLUTION
Since here is no out-of-the-box feature that could enable/disable checkboxes for row selection, this article describes how this can be done by using a few lines of code. The solution requires adding an unbound GridViewCheckBoxColumn which will be used to hold true/false value for every row depending on its selected state. Later, rows which are checked can be found by iterating through the DataAccessComponent.Rows collection. The code may look like this:


        private List<GridViewRowInfo> GetCheckedRows(RadGridView grid)  
        {  
            List<GridViewRowInfo> checkedRows = new List<GridViewRowInfo>();  
            foreach (GridViewRowInfo row in grid.Rows)  
            {  
                if (row.Cells["column1"].Value != null & row.Cells["column1"].Value != DBNull.Value)  
                {  
                    if (Convert.ToBoolean(row.Cells["column1"].Value))  
                    {  
                        checkedRows.Add(row);  
                    }  
                }  
 
            }  
            return checkedRows;  
        } 

 
Please, refer the attached sample projects for additional details.

Comments

If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.