windowsforms-devexpress-dot-xtragrid-dot-gridcontrol-16c1b273.md
Allows to customize the embedded data navigator.
Namespace : DevExpress.XtraGrid
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
[DXCategory("Appearance")]
public virtual ControlNavigator EmbeddedNavigator { get; }
<DXCategory("Appearance")>
Public Overridable ReadOnly Property EmbeddedNavigator As ControlNavigator
| Type | Description |
|---|---|
| ControlNavigator |
The data navigator.
|
Set the GridControl.UseEmbeddedNavigator property to true to enable the data navigator. The grid control displays the data navigator at the bottom. Use the EmbeddedNavigator property to customize the data navigator’s settings. You can display or hide certain command buttons, customize their appearance settings and hints.
You can also use the Grid’s ColumnViewOptionsBehavior.AllowAddRows and ColumnViewOptionsBehavior.AllowDeleteRows options to enable or disable the “Append” and “Delete” buttons.
The enabled state of specific buttons (for example, End Edit, Cancel Edit) is controlled automatically and cannot be changed using the button’s Enabled property. For example, the Grid automatically enables the “End Edit” button (that posts the edit value to a data source) when a user activates a cell’s editor, and disables the button when the cell editor closes.
Note
The Append button is disabled if the data source does not implement the IBindingList interface.
The following example displays a confirmation message after a user clicks the “Remove” command button:
using System.Windows.Forms;
using DevExpress.XtraEditors;
public Form1() {
InitializeComponent();
// Binds the Grid control to a data source.
gridControl1.DataSource = GetData();
// Handles clicks on data navigator buttons.
gridControl1.EmbeddedNavigator.ButtonClick += EmbeddedNavigator_ButtonClick;
}
private void EmbeddedNavigator_ButtonClick(object sender, NavigatorButtonClickEventArgs e) {
if(e.Button.ButtonType == NavigatorButtonType.Remove)
e.Handled = XtraMessageBox.Show("Do you want to delete the record?", "Warning", MessageBoxButtons.YesNo) == DialogResult.No;
}
Imports System.Windows.Forms
Imports DevExpress.XtraEditors
Public Sub New()
InitializeComponent()
' Binds the Grid control to a data source.
gridControl1.DataSource = GetData()
' Handles clicks on data navigator buttons.
AddHandler gridControl1.EmbeddedNavigator.ButtonClick, AddressOf EmbeddedNavigator_ButtonClick
End Sub
Private Sub EmbeddedNavigator_ButtonClick(ByVal sender As Object, ByVal e As NavigatorButtonClickEventArgs)
If e.Button.ButtonType = NavigatorButtonType.Remove Then
e.Handled = XtraMessageBox.Show("Do you want to delete the record?", "Warning", MessageBoxButtons.YesNo) = DialogResult.No
End If
End Sub
Note
You can also link an external ControlNavigator to the Grid control. Place the ControlNavigator control onto a Form and bind it to the Grid (ControlNavigator.NavigatableControl).
Read the following topic for detailed information and examples: Data Navigators.
In this example we change the visibility of two buttons of the embedded navigator: Append and Remove.
ControlNavigator navigator = gridControl1.EmbeddedNavigator;
navigator.Buttons.BeginUpdate();
try {
navigator.Buttons.Append.Visible = false;
navigator.Buttons.Remove.Visible = false;
}
finally {
navigator.Buttons.EndUpdate();
}
Dim navigator As ControlNavigator = GridControl1.EmbeddedNavigator
navigator.Buttons.BeginUpdate()
Try
navigator.Buttons.Append.Visible = False
navigator.Buttons.Remove.Visible = False
Finally
navigator.Buttons.EndUpdate()
End Try
See Also