Back to Devexpress

EditFormEventArgsBase.BindableControls Property

windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-editformeventargsbase.md

latest5.7 KB
Original Source

EditFormEventArgsBase.BindableControls Property

Provides access to the collection of controls used to edit the processed data record. Controls are indexed by field names or grid columns.

Namespace : DevExpress.XtraGrid.Views.Grid

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
public EditFormBindableControlsCollection BindableControls { get; }
vb
Public ReadOnly Property BindableControls As EditFormBindableControlsCollection

Property Value

TypeDescription
DevExpress.XtraGrid.EditForm.Helpers.EditFormBindableControlsCollection

An object that specifies the collection of controls used to edit the processed data record.

|

Remarks

To retrieve an editor for a particular field/column, use the corresponding GridColumn.FieldName property value or the corresponding GridColumn object.

csharp
private void gridView1_EditFormPrepared(object sender, DevExpress.XtraGrid.Views.Grid.EditFormPreparedEventArgs e) {
    Control colCityEditor = e.BindableControls[colCity];
    Control colAddressEditor = e.BindableControls["Address"];
    //..
}
vb
Private Sub gridView1_EditFormPrepared(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Grid.EditFormPreparedEventArgs)
    Dim colCityEditor As Control = e.BindableControls(colCity)
    Dim colAddressEditor As Control = e.BindableControls("Address")
End Sub

Example

When the Edit Form is displayed, focus moves to the first editor within the Edit Form. The following example shows how to handle the GridView.EditFormPrepared event to set focus to an editor corresponding to the focused GridColumn.

csharp
public partial class Form1 : Form {
    public Form1() {
        InitializeComponent();
        gridView1.EditFormPrepared += gridView1_EditFormPrepared;
    }

    private void gridView1_EditFormPrepared(object sender, DevExpress.XtraGrid.Views.Grid.EditFormPreparedEventArgs e) {
        GridView view = sender as GridView;
        if (e.BindableControls[view.FocusedColumn] != null)
            e.FocusField(view.FocusedColumn);
    }
}
vb
Public Partial Class Form1
    Inherits Form
    Public Sub New()
        InitializeComponent()
        AddHandler gridView1.EditFormPrepared, AddressOf gridView1_EditFormPrepared
    End Sub

    Private Sub gridView1_EditFormPrepared(sender As Object, e As DevExpress.XtraGrid.Views.Grid.EditFormPreparedEventArgs)
        Dim view as GridView = sender
        If e.BindableControls(view.FocusedColumn) IsNot Nothing Then
            e.FocusField(view.FocusedColumn)
        End If
    End Sub
End Class

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the BindableControls property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-grid-filter-lookup-column-based-on-another-column-editform/CS/FilterLookUpsEditForm/FormSingleSource.cs#L44

csharp
{
    baseLookUp = e.BindableControls["ProductType"] as LookUpEdit;
    filteredLookUp = e.BindableControls["Name"] as LookUpEdit;

winforms-grid-filter-lookup-column-based-on-another-column-editform/VB/FilterLookUpsEditForm/FormSingleSource.vb#L42

vb
Private Sub gridView1_EditFormPrepared(ByVal sender As Object, ByVal e As EditFormPreparedEventArgs)
    baseLookUp = TryCast(e.BindableControls("ProductType"), LookUpEdit)
    filteredLookUp = TryCast(e.BindableControls("Name"), LookUpEdit)

See Also

EditFormPrepared

Columns

VisibleColumns

FieldName

EditFormEventArgsBase Class

EditFormEventArgsBase Members

DevExpress.XtraGrid.Views.Grid Namespace