GridView.ShowingPopupEditForm Event
Occurs when an Edit Form is about to be displayed as a separate modal window.
Namespace: DevExpress.XtraGrid.Views.Grid
Assembly: DevExpress.XtraGrid.v24.1.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
Declaration
Event Data
The ShowingPopupEditForm event's data class is DevExpress.XtraGrid.Views.Grid.ShowingPopupEditFormEventArgs.
Remarks
You can respond to an Edit Form opening as a separate modal window by handling the ShowingPopupEditForm event. To get the handle that identifies a grid row for which the Edit Form is about to be displayed, use the RowHandle event argument. The BindableControls property provides access to the collection of editors on the Edit Form that are bound to the underlying data source. The EditForm property returns the XtraForm object representing the Edit Form that is about to be displayed.
Before the ShowingPopupEditForm event, the GridView.EditFormShowing and GridView.EditFormPrepared events fire.
Example
The code below handles the GridView.ShowingPopupEditForm
to do the following:
- Change the background of the text box that corresponds to the “Address” column.
- Access the labels that display column captions and change their font.
- Access the form’s Cancel button and subscribe to its Click event.
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Localization;
using DevExpress.XtraGrid.Views.Grid;
private void gridView1_ShowingPopupEditForm(object sender, ShowingPopupEditFormEventArgs e) {
// Paint the Address text box in yellow.
TextEdit textEditAddress = e.BindableControls["Address"] as TextEdit;
if(textEditAddress != null) textEditAddress.Properties.Appearance.BackColor = Color.LightYellow;
//Get the list of the form's labels
List<LabelControl> labels = new List<LabelControl>();
FindChildrenByType(e.EditForm, labels);
//Change labels' font
foreach (LabelControl label in labels)
label.Appearance.FontStyleDelta = FontStyle.Bold;
//Get the list of the form's buttons ('Cancel' and 'Update' buttons)
List<SimpleButton> buttons = new List<SimpleButton>();
FindChildrenByType(e.EditForm, buttons);
//Access the 'Cancel' button and subscribe to its Click event
foreach(SimpleButton btn in buttons)
if(btn.Text == GridLocalizer.Active.GetLocalizedString(GridStringId.EditFormCancelButton)) {
btn.Click += CancelButtonClick;
}
}
private void CancelButtonClick(object sender, EventArgs e) {
//...
(sender as SimpleButton).Click -= CancelButtonClick;
}
void FindChildrenByType<T>(Control parent, List<T> list) where T:class {
foreach(Control child in parent.Controls) {
if (child is T)
list.Add(child as T);
if (child.HasChildren)
FindChildrenByType<T>(child, list);
}
}