GridViewCheckBoxColumn not selectable

1 Answer 39 Views
GridView
Вадим
Top achievements
Rank 1
Iron
Iron
Вадим asked on 30 Jul 2024, 01:46 PM

Created a column like this:


if (operation == "viplata")
            {
                GridViewCheckBoxColumn checkBoxColumn = new GridViewCheckBoxColumn
                {
                    DataType = typeof(bool),
                    Name = "Выбрать",
                    FieldName = "Выбрать",
                    HeaderText = "Выбрать",
                    EditMode = EditMode.OnValueChange,
                    ReadOnly = false
                };
                checkBoxColumn.EnableHeaderCheckBox = true;
                radGridView1.MasterTemplate.Columns.Add(checkBoxColumn);
            }

The column is shown, but nothing can be selected. I have an event connected to DataGridView1_DoubleClick, so the checkboxes must be set by one click. How can I implement it?

I have grouping enabled in my grid.How can I make it so that when I press a key, only open checkBoxColumn groups are selected?Thanks for your help.

Dinko | Tech Support Engineer
Telerik team
commented on 02 Aug 2024, 10:13 AM

Thank you for the shared code snippet. In general, the EditMode property determines when the new value in the check box cell will be submitted. Setting the EditMode to OnValueChange as in the code snippet, clicking on the checkbox will automatically change the value in the data source object. The purpose of the GridViewCheckBoxColumn is to be bound to a boolean property inside your data source object. 

As for your second question, I will need more information regarding your requirements. Can you share images of what you have and what you want to happen when RadGridView is grouped? This way I could think for a way to achieve your requirement.

1 Answer, 1 is accepted

Sort by
0
Jesse
Top achievements
Rank 1
Iron
answered on 02 Aug 2024, 08:14 AM | edited on 05 Aug 2024, 03:21 AM

Hello,

I think you should enable Checkboxes to be Selected with a Single Click. To allow checkboxes to be selected with a single click instead of requiring a double-click, you can handle the CellClick event of the grid. In this event handler, you can toggle the checkbox state when a cell in the checkbox column is clicked. Here's an example:
2 player games

csharp


private void radGridView1_CellClick(object sender, GridViewCellEventArgs e)
{
    if (e.Column is GridViewCheckBoxColumn && e.RowIndex >= 0)
    {
        GridViewCheckBoxCellElement checkBoxCell = e.Row.Cells[e.Column.Name] as GridViewCheckBoxCellElement;
        checkBoxCell.Value = !Convert.ToBoolean(checkBoxCell.Value);
    }
}

Tags
GridView
Asked by
Вадим
Top achievements
Rank 1
Iron
Iron
Answers by
Jesse
Top achievements
Rank 1
Iron
Share this question
or