Back to Devexpress

DataNavigator.DataSource Property

windowsforms-devexpress-dot-xtraeditors-dot-datanavigator.md

latest6.7 KB
Original Source

DataNavigator.DataSource Property

Gets or sets a data source for the DataNavigator control.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DefaultValue(null)]
[DXCategory("Data")]
public object DataSource { get; set; }
vb
<DXCategory("Data")>
<DefaultValue(Nothing)>
Public Property DataSource As Object

Property Value

TypeDefaultDescription
Objectnull

A data source object whose data is managed by the data navigator.

|

Remarks

The DataNavigator control is used to navigate through the records in a data source and perform operations on the data. Thus, it needs to be associated with a data source in order to receive and manipulate data.

The DataSource property represents the object used as a data source. Generally, the data source object is represented by the DataSet component. The data source can contain a multiple set of data (several tables, for instance). Use the DataNavigator.DataMember property to specify the appropriate table whose contents are to be navigated and manipulated by the data navigator.

Example

The following code creates a new DataNavigator control, binds it to a data source, and specifies custom images for control buttons at runtime. Custom images are stored in an ImageCollection object.

csharp
using DevExpress.XtraEditors;

private void CreateDataNavigator() {
    // Create a new DataNavigator control
    DataNavigator dataNavigator = new DataNavigator();
    Controls.Add(dataNavigator);
    dataNavigator.Height = 40;
    dataNavigator.Dock = DockStyle.Bottom;
    // Bind to a data source
    dataNavigator.DataSource = productsBindingSource;
    // Specify the ImageCollection that stores custom images for DataNavigator buttons
    dataNavigator.Buttons.ImageList = imageCollection1;
    for (int i = 0; i < dataNavigator.Buttons.ButtonCollection.Count; i++) {
        dataNavigator.Buttons.ButtonCollection[i].ImageIndex = i;
    }
    dataNavigator.ShowToolTips = true;
}
vb
Imports DevExpress.XtraEditors

Private Sub CreateDataNavigator()
   ' Create a new DataNavigator control
   Dim DataNavigator As New DataNavigator()
   Controls.Add(DataNavigator)
   DataNavigator.Dock = DockStyle.Bottom
   dataNavigator.Height = 40
   ' Bind to a data source
   DataNavigator.DataSource = productsBindingSource
   ' Specify the ImageCollection that stores custom images for DataNavigator buttons
   DataNavigator.Buttons.ImageList = imageCollection1
   Dim i As Integer
   For i = 0 To DataNavigator.Buttons.ButtonCollection.Count - 1
      DataNavigator.Buttons.ButtonCollection(i).ImageIndex = i
   Next i
   DataNavigator.ShowToolTips = True
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the DataSource 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-richedit-use-images-in-mail-merge/CS/Form1.cs#L25

csharp
dataNavigator1.DataSource = NorthwindDataProvider.Categories;
}

winforms-data-navigator-bind-to-shared-source/CS/GridProject/Form1.cs#L42

csharp
dataNavigator1.DataSource = sampleBindingSource;
}

winforms-spreadsheet-control-create-a-data-entry-form/CS/DataEntryFormSample/MainForm.cs#L213

csharp
spreadsheetBindingManager1.DataSource = bindingSource1;
    dataNavigator1.DataSource = bindingSource1;
}

winforms-spreadsheet-use-cell-range-as-data-source/CS/RangeDataSource/Form1.cs#L71

csharp
gridControl1.DataSource = rangeDS;
dataNavigator1.DataSource = rangeDS;
linearScaleComponent1.DataBindings.Clear();

winforms-richedit-use-images-in-mail-merge/VB/Form1.vb#L22

vb
richEditControl1.Options.MailMerge.ViewMergedData = True
    dataNavigator1.DataSource = NorthwindDataProvider.Categories
End Sub

winforms-data-navigator-bind-to-shared-source/VB/GridProject/Form1.vb#L31

vb
gridControl1.DataSource = sampleBindingSource
    dataNavigator1.DataSource = sampleBindingSource
End Sub

winforms-spreadsheet-use-cell-range-as-data-source/VB/RangeDataSource/Form1.vb#L77

vb
gridControl1.DataSource = rangeDS
dataNavigator1.DataSource = rangeDS
linearScaleComponent1.DataBindings.Clear()

See Also

DataMember

DataNavigator Class

DataNavigator Members

DevExpress.XtraEditors Namespace