Xceed Grid for WinForms v4.3 Documentation
SetDataBinding Method (ComboBoxViewer)
Example 


Xceed.Grid.v4.3 Assembly > Xceed.Grid.Viewers Namespace > ComboBoxViewer Class : SetDataBinding Method
The data source used to populate the ComboBoxViewer, typed as System.Object.
A string that specifies the table to bind to within the object returned by the DataSource property.
Sets the DataSource and DataMember properties at run time.
Syntax
'Declaration
 
Public Sub SetDataBinding( _
   ByVal dataSource As Object, _
   ByVal dataMember As String _
) 
'Usage
 
Dim instance As ComboBoxViewer
Dim dataSource As Object
Dim dataMember As String
 
instance.SetDataBinding(dataSource, dataMember)
public void SetDataBinding( 
   object dataSource,
   string dataMember
)

Parameters

dataSource
The data source used to populate the ComboBoxViewer, typed as System.Object.
dataMember
A string that specifies the table to bind to within the object returned by the DataSource property.
Remarks

The following is a list of the supported data sources:

System.Data.DataTable Represents one table of in-memory data.
System.Data.DataView Represents a databindable, customized view of a System.Data.DataTable for sorting, filtering, searching, editing, and navigation.
System.Data.DataSet Represents an in-memory cache of data.
System.Data.DataViewManager Contains a default System.Data.DataViewSettingCollection for each System.Data.DataTable in a System.Data.DataSet.
Any component that implements the System.ComponentModel.IListSource interface. Provides functionality to an object to return a list that can be bound to a data source.
Any component that implements the System.Collections.IList interface. Represents a collection of objects that can be individually accessed by index.
Jagged arrays A jagged array is an array whose elements are arrays.

If the data source is a jagged array and rows are added or removed from the jagged array from outside of the ComboBoxViewer, then the jagged array must be reassigned to the DataSource property in order for the modifications to be reflected in the ComboBoxViewer.
Example
The following example demonstrates how to bind the ComboBoxViewer to a dataset filled by an ADO data adapter:
Imports Xceed.Editors
Imports System.Data.OleDb

Dim connectionString As String = "" 'connection query
Dim connection As New OleDbConnection( connectionString )

connection.Open()

Dim selectQuery As String = "SELECT * FROM Clients"
Dim dataAdapter As New OleDbDataAdapter( selectQuery, connection )
Dim dataSet As New DataSet( "Clients" )

dataAdapter.Fill( dataSet )

comboBoxViewer1.SetDataBinding( dataSet, "Clients" )
using Xceed.Editors;
using System.Data.OleDb;

string connectionString = ""; //connection query
OleDbConnection connection = new OleDbConnection( connectionString );

connection.Open();

string selectQuery = "SELECT * FROM Clients";
OleDbDataAdapter dataAdapter = new OleDbDataAdapter( selectQuery, connection );
DataSet dataSet = new DataSet( "Clients" );

dataAdapter.Fill( dataSet );

comboBoxViewer1.SetDataBinding( dataSet, "Clients" );
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ComboBoxViewer Class
ComboBoxViewer Members
DataSource Property
DataMember Property