I'm using devexpress tools. I have code below that basically checks each control on a form and sets an event handler to the control by check if the value has changed. upon form closing it will check if this is true and if it is, prompt to save. It works fine now, but i want to check if a gridview within a gridcontrol has changed. there is an event called cellvaluechanged under gridview. I want to add the handler to the gridview.cellvaluechanged, but i can't access it directly. It's inside a gridcontrol. how can i access this through code?
'If TypeOf c Is GridControl Then
' Dim cb As GridControl = CType(c, GridControl)
' AddHandler cb.ViewCollection(0).GridControl ... dont know how to access gridview
'End If
Here is my full solution working without the gridview check
Dim is_Dirty As Boolean = False
Private Sub AddDirtyEvent(ByVal ctrl As Control)
For Each c As Control In ctrl.Controls
If TypeOf c Is TextEdit Then
Dim tb As TextEdit = CType(c, TextEdit)
AddHandler tb.EditValueChanged, AddressOf SetIsDirty
End If
'If TypeOf c Is ComboBoxEdit Then
' Dim cb As ComboBoxEdit = CType(c, ComboBoxEdit)
' AddHandler cb.SelectedIndexChanged, AddressOf SetIsDirty
'End If
If c.Controls.Count > 0 Then
AddDirtyEvent(c)
End If
Next
End Sub
Private Sub SetIsDirty(ByVal sender As System.Object, ByVal e As System.EventArgs)
is_Dirty = True
End Sub
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
If is_Dirty = True Then
Dim dr As DialogResult = MessageBox.Show("Do you want save changes before leaving?", "Closing Well Info", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2)
If dr = Windows.Forms.DialogResult.Yes Then
SimpleButtonSave.PerformClick()
End If
End If