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

GridViewBooleanColumn: strange behaviour when work with keyboard

3 Answers 171 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Emanuele Savarese
Top achievements
Rank 1
Emanuele Savarese asked on 13 Jan 2008, 10:16 PM
WinForms RadControls Q3 2007
Visual Studio 2005
.NET 2.0

In other grid when I work with check box column I can set value of checkbox pressing space bar. I tried to set value with space bar but RadGridView have a strange behaviour.

1. on first load on first row press once space bar but grid doesn't check
2. after few seconds press another time space bar and grid check cell
3. go to second row with arrow keys
4. press space bar first time on second row and... check on first row disappear ?!? and on check on second row stay off
5. press space bar second time on second row and appears check on second row
6. go to third row and appers check also on the first row ?!?!?

I want a simple way to set checkbox in column similar Microsoft standard control ListView when set with CheckBoxes  = true.

Placed a listview and a radgridview this code can reproduce error and my favourite behaviour.

Thanks in advance,
Emanuele Savarese

        private void Form1_Load(object sender, EventArgs e) 
        { 
            DataTable dt = new DataTable(); 
            dt.Columns.Add("From", typeof(bool)); 
            dt.Columns.Add("To", typeof(bool)); 
            dt.Columns.Add("Description", typeof(string)); 
 
            dt.Rows.Add(false, false, "hi1"); 
            dt.Rows.Add(false, false, "hi2"); 
            dt.Rows.Add(false, false, "hi3"); 
            dt.Rows.Add(false, false, "hi4"); 
            dt.Rows.Add(false, false, "hi5"); 
            dt.Rows.Add(false, false, "hi5"); 
            dt.Rows.Add(false, false, "hi6"); 
            dt.Rows.Add(false, false, "hi7"); 
            dt.Rows.Add(false, false, "hi8"); 
            dt.Rows.Add(false, false, "hi9"); 
            dt.Rows.Add(false, false, "hi10"); 
 
            radGridView1.MasterGridViewTemplate.AutoGenerateColumns = false
            radGridView1.Columns.Add(new GridViewBooleanColumn("From")); 
            radGridView1.Columns[0].IsPinned = true
            radGridView1.Columns.Add(new GridViewBooleanColumn("To")); 
            radGridView1.Columns[1].IsPinned = true
            radGridView1.Columns.Add(new GridViewTextBoxColumn("Description")); 
            radGridView1.Columns[2].ReadOnly = true
            radGridView1.Columns[2].Width = 600
 
            radGridView1.SelectionMode = GridViewSelectionMode.FullRowSelect; 
            radGridView1.DataSource = dt
 
            listView1.View = View.Details; 
            listView1.FullRowSelect = true
            listView1.CheckBoxes = true;             
            listView1.Columns.Add("To"); 
            listView1.Columns.Add("Description"); 
            listView1.Items.Add(new ListViewItem(new string[] { "hi", "hi1" })); 
            listView1.Items.Add(new ListViewItem(new string[] { "hi", "hi2" })); 
            listView1.Items.Add(new ListViewItem(new string[] { "hi", "hi3" })); 
        } 



3 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 15 Jan 2008, 05:04 PM
Hi Emanuele Savarese,

I have replied to your previous post. Here is the text:

Unfortunately, this appears to be a bug. It is not related to the checkbox editor, but rather to the current cell in the RadGridView. This has been logged in our bug tracking system with the highest priority and will be addressed as soon as possible.

We are sorry for the inconvenience. Your telerik points have been updated.

Regards,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Quinn
Top achievements
Rank 2
answered on 24 Jul 2012, 09:21 PM
Has this bug been fixed?
0
Stefan
Telerik team
answered on 27 Jul 2012, 01:11 PM
Hi Quinn,

Yes, checking a check box of a cell with space is now working correctly. Please give it a try and let us know if you have any difficulties.
 
All the best,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Loren
Top achievements
Rank 1
commented on 13 Sep 2024, 05:59 PM

There still seems to be an issue with the last checked row in the collection when using spacebar. I check a few rows using arrow keys and space bar, and the last one is still showing that it's false. I checked the CellValueChanged event and it is definitely firing, but when I query the checkbox column for that row, it's acting like there is no checkbox column present at all.

I haven't tested with other data sources; I'm binding to a custom collection of objects with no data-bound field for the checkbox column.

foreach (GridViewRowInfo row in HostGrid.Rows)
{
    bool rowChecked = (bool?)row.Cells["CheckBox"].Value ?? false;

    if (!rowChecked) continue;

    checkedRows.Add(row);
}

The above code is resulting in the continue statement being hit for the last checked row in the sequence, resulting in checkedRows-1 results.

Dinko | Tech Support Engineer
Telerik team
commented on 16 Sep 2024, 12:47 PM

Hi Loren,

I will start with that the new value inside the cell will be committed when the user leaves the cell (close the editor). Clicking on a cell will trigger the edit mode, but the new typed value is still not confirmed. This is the behavior that you observe with the GridViewCheckBoxColumn. Navigating to a cell with the keyboard and pressing space will change the checkbox value of the editor and the new value will be committed when you leave the cell, focus different controls so that the RadGridView loses focus, etc. 

You could change this behavior by setting the EditMode property of the control to OnValueChange.

 this.radGridView1.Columns.Insert(0,new GridViewCheckBoxColumn() { EditMode = EditMode.OnValueChange } );

Give this a try and let me know if it works for you. If not, can you modify my test project to mimic your set-up and attached it again so that I can take a closer look and debug it.

Loren
Top achievements
Rank 1
commented on 17 Sep 2024, 06:38 PM

Hi Dinko,

That worked! Thank you.

Tags
GridView
Asked by
Emanuele Savarese
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Quinn
Top achievements
Rank 2
Stefan
Telerik team
Share this question
or