With the RadGridView, if I have a checkboxcolumn and the user clicks on the checkbox, the value is not updated in my datasource (BindingList<> of business objects) until the user clicks off of the row. How can I force the update to happen immediately when they click on the checkbox? ValueChanging and ValueChanged don't seem to update my BindingList when I want them to.
Thanks!
Thanks!
7 Answers, 1 is accepted
0
Hi Adam,
You are correct. Currently, if you only check/uncheck RadCheckBox, the BindingList will not be updated accordingly. We will address this issue in one of our next versions. For the time being, you can set the value of the GridCheckBoxCellElement in the RadGridView_ValueChanged event handler as shown below. This will update your BindingList:
I hope this helps. If you have additional questions, feel free to contact me.
Regards,
Nikolay
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
You are correct. Currently, if you only check/uncheck RadCheckBox, the BindingList will not be updated accordingly. We will address this issue in one of our next versions. For the time being, you can set the value of the GridCheckBoxCellElement in the RadGridView_ValueChanged event handler as shown below. This will update your BindingList:
private void radGridView1_ValueChanged(object sender, EventArgs e) |
{ |
((GridCheckBoxCellElement)sender).Value = ((RadCheckBoxEditor)((GridCheckBoxCellElement)sender).Children[0]).Value; |
} |
I hope this helps. If you have additional questions, feel free to contact me.
Regards,
Nikolay
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Adam
Top achievements
Rank 2
answered on 11 Nov 2008, 12:10 PM
This works great!! This won't work for Textboxcells though I imagine, since you would still have to click off of the textbox for the TextChanged event to fire on the editor. Is that a safe assumption?
0
Hi Adam,
TextChaning, TextChanged events of the RadTextBoxEditor and ValueChanged event of RadGridView are fired whenever you change a value in an editor. So, let's say you type "123" in the editor - this set of events will be fired three times - one for "1", one for "12" and one for "123".
For the ValueChanged event, you can check whether the sender is a GridViewCheckBoxColumn, and if 'yes' execute the custom logic. In addition, I would suggest an easier approach to get the correct value by the ActiveEditor property:
If you do not want the BindingList to update on each letter typed, you can just press the Enter key to close the editor. This will update the BindingList and you do not need to click off the cell.
If you need additional assistance, feel free to contact me
Regards,
Nikolay
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
TextChaning, TextChanged events of the RadTextBoxEditor and ValueChanged event of RadGridView are fired whenever you change a value in an editor. So, let's say you type "123" in the editor - this set of events will be fired three times - one for "1", one for "12" and one for "123".
For the ValueChanged event, you can check whether the sender is a GridViewCheckBoxColumn, and if 'yes' execute the custom logic. In addition, I would suggest an easier approach to get the correct value by the ActiveEditor property:
if(sender is GridCheckBoxCellElement) |
{ |
((GridCheckBoxCellElement)sender).Value = this.radGridView1.ActiveEditor.Value; |
} |
If you do not want the BindingList to update on each letter typed, you can just press the Enter key to close the editor. This will update the BindingList and you do not need to click off the cell.
If you need additional assistance, feel free to contact me
Regards,
Nikolay
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Peter
Top achievements
Rank 1
answered on 27 May 2012, 09:11 PM
I am using Q1 2011. Please can you provide me with this code in VB.Net?
Thanks
private void radGridView1_ValueChanged(object sender, EventArgs e) |
{ |
((GridCheckBoxCellElement)sender).Value = ((RadCheckBoxEditor)((GridCheckBoxCellElement)sender).Children[0]).Value; |
} |
0
Hi Peter,
I hope this helps.
Kind regards,
Nikolay
the Telerik team
In the context of Q1 2011 the code snippet looks like this:
Private
Sub
RadGridView1_ValueChanged(sender
As
Object
, e
As
System.EventArgs)
Handles
RadGridView1.ValueChanged
If
TypeOf
sender
Is
RadCheckBoxEditor
Then
Me
.RadGridView1.CurrentCell.Value =
Me
.RadGridView1.ActiveEditor.Value
End
If
End
Sub
I hope this helps.
Kind regards,
Nikolay
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Peter
Top achievements
Rank 1
answered on 29 May 2012, 07:56 PM
Hi Nikolay
Thank you for your excellent support. It ALMOST solves my problem 100%. Only issue is that after ticking/unticking the checkbox, the "pencil" remains in the row indicator column and the horizontal arrow is only replaced if the user clicks on another cell. For my app, the horizontal arrow must display as soon as the mouse button is released.
The RadGridView1 is not bound to any data source. It is manually populated using RadGridView1.Rows.Add.
Once I can achieve this, the RadGridView will be PERFECT for my app
Thanks
Peter
Thank you for your excellent support. It ALMOST solves my problem 100%. Only issue is that after ticking/unticking the checkbox, the "pencil" remains in the row indicator column and the horizontal arrow is only replaced if the user clicks on another cell. For my app, the horizontal arrow must display as soon as the mouse button is released.
The RadGridView1 is not bound to any data source. It is manually populated using RadGridView1.Rows.Add.
Once I can achieve this, the RadGridView will be PERFECT for my app
Thanks
Peter
0
Hello Peter,
Nikolay
the Telerik team
Thank you for writing back.
The current RadGridView behavior does not allow ending the edit mode right after the end-user releases the mouse button.
Let us know if you have other questions.
Nikolay
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>