Back to Devexpress

GridOptionsSelection.CheckBoxSelectorField Property

windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-gridoptionsselection-583d4918.md

latest5.2 KB
Original Source

GridOptionsSelection.CheckBoxSelectorField Property

Gets or sets the name of the field in the data source that is bound to the check box column.

Namespace : DevExpress.XtraGrid.Views.Grid

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
[DefaultValue("")]
[XtraSerializableProperty]
public virtual string CheckBoxSelectorField { get; set; }
vb
<DefaultValue("")>
<XtraSerializableProperty>
Public Overridable Property CheckBoxSelectorField As String

Property Value

TypeDefaultDescription
StringString.Empty

A string value that specifies the name of the field in the data source that is bound to the check box column.

|

Property Paths

You can access this nested property as listed below:

Object TypePath to CheckBoxSelectorField
GridView

.OptionsSelection .CheckBoxSelectorField

|

Remarks

Users can use check boxes to select rows in a grid.

To display the check box column:

Use the CheckBoxSelectorField property to bind the check box column to a field in the data source. When a user selects a row, the change is automatically reflected in the data source.

csharp
gridView1.OptionsSelection.MultiSelect = true;
gridView1.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
gridControl1.DataSource = GetData();
gridView1.Columns["IsSelected"].Visible = false;
gridView1.OptionsSelection.CheckBoxSelectorField = "IsSelected";

public DataTable GetData() {
    DataTable table = new DataTable();
    table.Columns.Add("IsSelected", typeof(Boolean));
    table.Columns.Add("ID", typeof(String));
    for (int i = 0; i < 10; i++)
        table.Rows.Add(new object[] { i % 2 == 0 ? true : false, "Item " + i.ToString() });
    return table;
}
vb
gridView1.OptionsSelection.MultiSelect = True
gridView1.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect
gridControl1.DataSource = GetData()
gridView1.Columns.ColumnByFieldName("IsSelected").Visible = False
gridView1.OptionsSelection.CheckBoxSelectorField = "IsSelected"

Private Function GetData() As DataTable
    Dim dt As New DataTable()
    dt.Columns.Add("IsSelected", GetType(Boolean))
    dt.Columns.Add("ID", GetType(String))
    For i As Integer = 0 To 10
        dt.Rows.Add(False, "Item " + i.ToString())
    Next i
    Return dt
End Function

You can also handle the ColumnView.SelectionChanged event to perform custom actions when a row is selected.

Read the following topic for detailed information: Selection Binding.

Important

Do not use Selection Binding in Instance Feedback Mode. When selection Binding is enabled, the grid control processes data as in normal mode, negating all the advantages of Instant Feedback mode.

See Also

MultiSelect

MultiSelectMode

GridOptionsSelection Class

GridOptionsSelection Members

DevExpress.XtraGrid.Views.Grid Namespace