|
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.
Please
Sign In
to rate this article.