This is a migrated thread and some comments may be shown as answers.

option to check a single row in gridview

7 Answers 194 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
rajesh
Top achievements
Rank 1
rajesh asked on 20 May 2009, 07:33 AM
We have a requirement to check a single row in the radgridview.
What should be the approach for this requirement using RadGridView, we need to use a checkbox column or is there any radio button column.
Please help me regarding the above.

7 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 22 May 2009, 12:03 PM
Hi rajesh,

Thank you for writing.

If you want to mark some rows in RadGridView you could use unbound GridViewCheckBoxColumn. Please review the following sample code how to insert a check box column:

GridViewCheckBoxColumn checkColumn = new GridViewCheckBoxColumn();  
checkColumn.UniqueName = "Select";  
checkColumn.HeaderText = "Select";  
this.radGridView1.Columns.Insert(0, checkColumn);   
 
Do not hesitate to contact me again if you have other questions.

Sincerely yours,
Martin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
rajesh
Top achievements
Rank 1
answered on 25 May 2009, 06:47 AM
Hi Martin,
Thanks for the response.
Can we make the checkbox column of radgridview to accept only one row to be checked at a time and uncheck the previously checked row on checking a new row?
some way to mimic the radio button functionality of any one selected at any time.
This is the requirement. Can you please help me at the earliest. 

Thanks & regards
Rajesh
0
Martin Vasilev
Telerik team
answered on 27 May 2009, 10:31 AM
Hello rajesh,

Thank you for getting back to me.

You can use the grid's ValueChanging event to implement described behavior. Please, review the code-block below:

private void Form1_Load(object sender, EventArgs e)  
{  
    GridViewCheckBoxColumn col = new GridViewCheckBoxColumn();  
    col.HeaderText = "Select";  
    this.radGridView1.MasterGridViewTemplate.Columns.Insert(0, col);  
 
    this.radGridView1.ValueChanging += new ValueChangingEventHandler(radGridView1_ValueChanging);  
}  
 
void radGridView1_ValueChanging(object sender, ValueChangingEventArgs e)  
{  
    if (this.radGridView1.CurrentCell.ColumnIndex == 0 && (bool)e.NewValue == true)  
    {  
        for (int i = 0; i < this.radGridView1.MasterGridViewTemplate.Rows.Count; i++)  
        {  
            this.radGridView1.MasterGridViewTemplate.Rows[i].Cells[0].Value = false;  
        }  
    }  

Hope this helps. Do not hesitate to contact me again if you need additional assistance.

Kind regards,
Martin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
rajesh
Top achievements
Rank 1
answered on 28 May 2009, 06:30 AM
Hi Martin,
             Its very much helpful. Thanks a lot for the response.
             Is there a way to use a radiobutton column in radgridview for winforms. Which I was not able to find.
             Please let me know as the requirement was to use a telerik radgridview and to use a radio button column in it.
             Help me if I could be able to do the same.
             You are really helpful.

thanks & regards,
Rajesh
0
Martin Vasilev
Telerik team
answered on 29 May 2009, 04:36 PM
Hello rajesh,

Thank you for the question.

RadGridView does not support a RadioButton column out-of-the-box. Nevertheless, you could try implementing this scenario by adding a RadRadioButtonElement to the CustomCellElement or CellFormatting event. You can find more guidance on how to do that in the following help and KB articles.

Write me back if you have other questions.

Regards,
Martin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Igor Ashmetkov
Top achievements
Rank 1
answered on 13 Sep 2011, 07:07 AM
Hello!
Does anyone know how to allow  check only a single row not in code behind, because I use MVVM model?

0
Martin Vasilev
Telerik team
answered on 15 Sep 2011, 04:27 PM
Hello Igor,

Thank you for writing.

RadGridView for Winforms does not support checking only a single row by default hence there is not a way to implement this feature without additional code.

If your question is not related to Winforms, please open a new thread in the appropriate section.

Let me know if you have any additional questions.

All the best,
Martin Vasilev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
General Discussions
Asked by
rajesh
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
rajesh
Top achievements
Rank 1
Igor Ashmetkov
Top achievements
Rank 1
Share this question
or