option to check a single row in gridview

8 posts, 0 answers
  1. rajesh
    rajesh avatar
    4 posts
    Member since:
    Mar 2009

    Posted 20 May 2009 Link to this post

    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.

  2. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 22 May 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. rajesh
    rajesh avatar
    4 posts
    Member since:
    Mar 2009

    Posted 25 May 2009 Link to this post

    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
  5. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 27 May 2009 Link to this post

    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.
  6. rajesh
    rajesh avatar
    4 posts
    Member since:
    Mar 2009

    Posted 28 May 2009 Link to this post

    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
  7. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 29 May 2009 Link to this post

    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.
  8. Igor Ashmetkov
    Igor Ashmetkov avatar
    12 posts
    Member since:
    Oct 2008

    Posted 13 Sep 2011 Link to this post

    Hello!
    Does anyone know how to allow  check only a single row not in code behind, because I use MVVM model?

  9. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 15 Sep 2011 Link to this post

    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 >>

Back to Top
UI for WinForms is Visual Studio 2017 Ready