windowsforms-9508-controls-and-libraries-editors-and-simple-controls-examples-how-to-respond-to-editors-value-modification.md
The following sample code handles the RepositoryItem.Modified event of a MemoEdit control to make the toolBarSaveButton of the toolBar1 control enabled each time the end-user starts to change memo edit contents. The ButtonClick event is handled in order to validate the memo editor using the BaseEdit.DoValidate method and to perform specific actions in response to button click events (for example, you can save memo edit contents to a file). Once all necessary operations are performed, toolBarSaveButton is disabled.
using System.Windows.Forms;
using DevExpress.XtraEditors;
// ...
private void memoEdit1_Modified(object sender, System.EventArgs e) {
toolBarSaveButton.Enabled = true;
}
private void toolBar1_ButtonClick(object sender, ToolBarButtonClickEventArgs e) {
// Checking whether the toolBarSaveButton has been clicked
if (e.Button == toolBarSaveButton){
// Validating the memoEdit1
memoEdit1.DoValidate();
/*
*
* Here you can save the memoEdit1 contents or
* perform some other specific actions in response to button click
*/
// Making the button disabled
e.Button.Enabled = false;
}
}
Imports DevExpress.XtraEditors
' ...
Private Sub MemoEdit1_Modified(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles MemoEdit1.Modified
toolBarSaveButton.Enabled = True
End Sub
Private Sub ToolBar1_ButtonClick(ByVal sender As Object, _
ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
' Checking whether the toolBarSaveButton has been clicked
If e.Button Is toolBarSaveButton Then
' Validating the memoEdit1
MemoEdit1.DoValidate()
'
'
' Here you can save the memoEdit1 contents or
' perform some other specific actions in response to button click
'
' Making the button disabled
e.Button.Enabled = False
End If
End Sub