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

CellValueChanged event not fired

5 Answers 1092 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Baldwin
Top achievements
Rank 1
Baldwin asked on 10 Nov 2010, 02:57 PM
Hello everybody.

I'm having the current problem with RadGridView (using Q2 2010):

The GUI has the following structure: RadRibbonForm contains SplitPlanel contains UserControl contains RadGridView.
Now, the GridView is bound to a List of objects. I'm using a CheckBox column for one property.

Now, I click into the checkbox cell, changing the ToggleState of the checkbox, but do not leave the cell by clicking on a different row. I do some necessary logic in the GridView_CellValueChanged event handler.
The I click the Save-Button which is located on the RibbonForms QuickAccessBar, but the data is not correctly saved.

After debugging, I realized that the CellValueChanged is neither triggered, when I click into the cell, nor when I click the Save-Button (would have thought so, because the cell should lose focus, accepting my data change).
If I click into a different row, my change to the combobox is accepted and correctly saved.

What can I do to solve this problem? Is there a method to make the grid change its cell values without leaving the edited row?

Thanks for any help

5 Answers, 1 is accepted

Sort by
0
Baldwin
Top achievements
Rank 1
answered on 10 Nov 2010, 03:17 PM
It seems I was a bit quick asking for help, as I found a solution myself:
I call manually the EndEdit() method of the GridView as first step of my saving routine.

I still wonder if there's a better way to achieve this.
0
Richard Slade
Top achievements
Rank 2
answered on 10 Nov 2010, 03:29 PM
Hi Baldwin, 

No, that's the way to do it. Register the ValueChanged event on the RadGrid. See the small sample below: 

Imports Telerik.WinControls.UI
Imports Telerik.WinControls
 
Public Class Form1
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.RadGridView1.Columns.Add(New GridViewCheckBoxColumn("Checkbox"))
        Me.RadGridView1.Columns.Add(New GridViewTextBoxColumn("Text"))
        Dim rowInfo As GridViewRowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = True
        rowInfo.Cells(1).Value = "Some Text"
        rowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = False
        rowInfo.Cells(1).Value = "More Text"
 
    End Sub
 
    Private Sub RadGridView1_CellValueChanged(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles RadGridView1.CellValueChanged
        If e.Value IsNot Nothing Then
            RadMessageBox.Show(e.Value.ToString())
        End If
 
    End Sub
 
 
    Private Sub RadGridView1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadGridView1.ValueChanged
        Me.RadGridView1.EndEdit()
        Me.RadGridView1.BeginEdit()
    End Sub
End Class

hope that helps
Richard
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 10 Nov 2010, 03:34 PM
A small change to the Valuechanged event so it only performs this behavior for checkbox columns

Private Sub RadGridView1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadGridView1.ValueChanged
    If Me.RadGridView1.CurrentCell IsNot Nothing Then
        If TypeOf Me.RadGridView1.CurrentCell.ColumnInfo Is GridViewCheckBoxColumn Then
            Me.RadGridView1.EndEdit()
        End If
    End If
End Sub

Any other questions, let me know
Richard
0
Richard Slade
Top achievements
Rank 2
answered on 10 Nov 2010, 03:34 PM
It's also been covered a little in this forum post
Richard
0
Baldwin
Top achievements
Rank 1
answered on 16 Nov 2010, 10:32 AM
Thanks for the information.
I was quite content with the solution anyway.
Tags
GridView
Asked by
Baldwin
Top achievements
Rank 1
Answers by
Baldwin
Top achievements
Rank 1
Richard Slade
Top achievements
Rank 2
Share this question
or