Enable disable checkbox in RadGridView

4 posts, 0 answers
  1. Rajeev
    Rajeev avatar
    10 posts
    Member since:
    Apr 2008

    Posted 11 Apr 2008 Link to this post

    Hi,

    I have RadGridView populated and it has first column as boolean column shown as checkbox on UI. I need to disable some checkbox on RadGridview based on some data on other column (means user can't click or do any operation.) and need to select and Unselect some checkbox. I tried cellformatting event and cellClick event but no success. I treid to access checkboxelement but it don't have any check property. Please help me how to access checkbox cell element at these events. Or is there any other event???

    GridViewBooleanColumn

    columnA = new GridViewBooleanColumn();

    columnA.HeaderTextAlignment =

    ContentAlignment.MiddleLeft;

    columnA.HeaderText =

    "";

    columnA.DataField =

    "Check";

    columnA.ReadOnly =

    false;

    columnA.Width = 20;

    columnA.AllowResize =

    false;

    columnA.MinWidth = 20;

    radDownLoadListGridView.MasterGridViewTemplate.Columns.Add(columnA);


    ...........................

    private void radDownLoadListGridView_CellClick(object sender, GridViewCellEventArgs e)

    {

    if (e.ColumnIndex == 0)

    {

    if (radDownLoadListGridView.CurrentRow.Cells[9].Value.ToString().ToLower() == "y")

    {

    (radDownLoadListGridView.CurrentCell).Column.ReadOnly =

    false;

    ((Telerik.WinControls.UI.

    GridCheckBoxCellElement)(radDownLoadListGridView.CurrentCell)).IsReadOnly = false;

    ((Telerik.WinControls.UI.

    GridCheckBoxCellElement)(radDownLoadListGridView.CurrentCell)).IsSelected = true;

    }

    else

    {

    (radDownLoadListGridView.CurrentCell).Column.ReadOnly =

    false;

    }

    }

    }

  2. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 14 Apr 2008 Link to this post

    Hello Rajeev,

    Thank you for contacting us.

    Yes, you can do this by processing the CellFormatting event. Consider the code snippet below:

    void radDownLoadListGridView_CellFormatting(object sender, CellFormattingEventArgs e) 
        if (e.CellElement.ColumnIndex == 0) 
        { 
            if ((int)this.radDownLoadListGridView.CurrentRow.Cells[2].Value.ToString().ToLower() == "y"
            { 
                e.CellElement.ColumnInfo.ReadOnly = true
            } 
            else 
            { 
                e.CellElement.ColumnInfo.ReadOnly = false
            } 
        } 

    I hope this helps. Feel free to contact me again, if you have other questions.

    Sincerely yours,
    Jack
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Prashu
    Prashu avatar
    17 posts
    Member since:
    May 2013

    Posted 02 Sep 2013 Link to this post

    hi all 


    i have three checkboxes in grid footer .. if i check one the other two should not allow to check how to implement it. uisng C#
  5. George
    Admin
    George avatar
    500 posts

    Posted 05 Sep 2013 Link to this post

    Hello Prashanth,

    Thank you for contacting us.

    Can you please provide me with some additional information since the provided so far seems insufficient for me?

    I am shooting in the dark here, however if you have three check box columns and you want to always have just one check box checked in a row, you can use the grid's ValueChanging event, which will get triggered when a checkbox value is changed, to uncheck the rest of the check boxes in this row.

    Looking forward to your reply.
     
    Regards,
    George
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top