How can I select multiple check boxes in radgrid and select All

9 posts, 1 answers
  1. Anoop
    Anoop avatar
    76 posts
    Member since:
    Sep 2006

    Posted 26 Oct 2011 Link to this post

    How can I select multiple check boxes in radgrid and select All

     

    I am using RadGridview which view a data from sql database with one GridViewCheckBoxColumn.

     

    Once the checkbox is clicked the whole row is deleted as I want, However I wanna allow that for multiple rows at the same time.

     

    Also I want to select all

     

    Is that possible?

     

    In my grid I should click twice to check the box! How can I avoid that?

     

    All the columns in the grid is read only except the checkbox column

     

    Thanks and regards

  2. Answer
    Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 31 Oct 2011 Link to this post

    Hi Anoop,

    Thank you for writing.

    I am not sure if I understand your scenario very well. However, if you need to add an unbound check-box column for selecting and deleting rows in RadGridView, you may take a look at following KB Article, which describes how to use check-box with a select all option:
    Add "Check All" in the header cell for a GridViewCheckBoxColumn

    Hope this helps. Let me know if you have any additional questions.

    Kind regards,
    Martin Vasilev
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Shlomo Pleban
    Shlomo Pleban avatar
    5 posts
    Member since:
    Oct 2006

    Posted 09 May 2013 Link to this post

    Hi,

    I added the class to my project.
    Now I am trying to define the custom header column but it doesn't works for me ...

    This is how I try to define the column:
    var chkCol = new GridViewCheckBoxColumn
                                        {
                            AutoSizeMode = BestFitColumnMode.None,
                            Width = 40,
                            ThreeState = false,
                            AllowSort = false,
                            Name = "includeDataGridViewCheckBoxColumn",
                            FieldName = includeColumnName
                        };
       GridRowElement headerRow = null; // new GridRowElement();
       var hdrCell = new Input.DataGrid.CheckBoxHeaderCellTelerik(chkCol, headerRow);

    What i want is to see in the checkbox column header the check box which select / un-select all

    Thanks
  5. Anton
    Admin
    Anton avatar
    167 posts

    Posted 14 May 2013 Link to this post

    Hi Shlomo,

    Thank you for writing.

    I assume that you want to exchange the default header cell with your custom one. If so, your question has already been answered in the ticket "How do I add a custom cell to the grid header", but I am copying the answer here so the community can benefit from it.

    There are two ways to use custom header cell in RadGridView:

    1. Through custom column with a custom cell as described in the KB. This approach has several steps:

    •  Create custom column and override GetCellType method. This method exchange the type of the default header cell with the custom one.
    Copy Code
    public class CustomCheckBoxColumn : GridViewCheckBoxColumn
    {
        public override Type GetCellType(GridViewRowInfo row)
        {
            if (row is GridViewTableHeaderRowInfo)
            {
                return typeof(CheckBoxHeaderCell);
            }
            return base.GetCellType(row);
        }
    }
    • Insert your custom column in RadGridView. Consider the following code snippet:
    Copy Code
    private void AddCheckColumn()
    {
        CustomCheckBoxColumn checkColumn = new CustomCheckBoxColumn();
        checkColumn.Name = "Select";
        checkColumn.HeaderText = "All";
        this.radGridView1.Columns.Insert(0, checkColumn);
    }

    2. Through the CreateCell event of RadGridView. This approach has several steps as well:
    • Add standard checkbox column - GridViewCheckBoxColumn
    Copy Code
    private void AddCheckColumn()
    {
        GridViewCheckBoxColumn checkColumn = new GridViewCheckBoxColumn();
        checkColumn.Name = "Select";
        checkColumn.HeaderText = "All";
        this.radGridView1.Columns.Insert(0, checkColumn);
    }
    • Subscribe to the CreateCell event of RadGridView and replacen the default GridHeaderCellElement with your custom one.
    Copy Code
    void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e)
    {
        if (e.CellType == typeof(GridHeaderCellElement) && e.Column.HeaderText=="All")
        {
            e.CellType = typeof(CheckBoxHeaderCell);
        }
    }

    Attached is a sample project that comprises the code above.

    We highly appreciate your effort to make more visible this topic for the community. However, we will be glad if you are using only one communication channel for your future support communication. 

    If you have further questions, feel free to write back.

    Greetings,
    Anton
    the Telerik team
    RadChart for WinForms is obsolete. Now what?
  6. cevdet
    cevdet avatar
    19 posts
    Member since:
    Jan 2015

    Posted 26 Jan 2015 in reply to Anton Link to this post

    How can I add CustomCheckBoxColumn to grid in design mode ? When I add in design mode column disappears.
  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 27 Jan 2015 Link to this post

    Hi Cevdet,

    Thank you for writing.

    After placing the code for the custom column in a separate file and building the project you will be able to see the column in the Columns editor of RadGridView. From there, you can add it to the grid and it will be shown when you run the form. I have just tested this. If you experience any issues with this case, please open a support ticket and attach your project there for our team to investigate. 

    As to the check box in the header cell, as of Q2 2014 SP1, RadGridView has this functionality built-in, so it is no longer needed to use custom column. Simply use the EnableHeaderCheckBox property of GridViewCheckBoxColumn.

    Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  8. cevdet
    cevdet avatar
    19 posts
    Member since:
    Jan 2015

    Posted 27 Jan 2015 in reply to Stefan Link to this post

    Hi Stefan,

    Thank you for response.

    After build project the column added and I saw it, but now there is another issue :

    in checkbox_ToggleStateChanged event theese codes work successfully
                    for (int i = 0; i < this.ViewInfo.Rows.Count; i++)
                    {
                        this.ViewInfo.Rows[i].Cells[this.ColumnIndex].Value = valueState;
                    }
    I changed theese codes for my project than they did not worked. My codes related above codes :
    List<int> Ids = this.GridControl.ChildRows.Select(O => (int)O.Cells["CUSTOMER_MAIN_ID"].Value).ToList();
    foreach (DataRow Row in (this.GridControl.DataSource as DataTable).AsEnumerable().Where(O => Ids.Contains(O.Field<int>("CUSTOMER_MAIN_ID"))))
    {
             Row["Select"] = valueState;
    }

    Shortly, customcheckboxcolumn does'nt work with datasource of radgridview in my project, please help me ?
  9. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 27 Jan 2015 Link to this post

    As I mentioned, header check box is available out of the box with a single property setting, so you do not need to use custom column at all. Still, if you have to do that, please open a support ticket and send us your project and description of your goal, so we can investigate the precise case and help you with it.

    Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  10. cevdet
    cevdet avatar
    19 posts
    Member since:
    Jan 2015

    Posted 27 Jan 2015 in reply to Stefan Link to this post

    Ok, I understood it, but we can not upgrade telerik to Q2 2014 SP1 because we are not ready for this. I will try support ticket, thanks.
Back to Top
UI for WinForms is Visual Studio 2017 Ready