Assembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public class TableBindingAdapter : IBindingList, IList, ICollection, IEnumerable, ITypedList |
Visual Basic (Declaration) |
---|
Public Class TableBindingAdapter _ Implements IBindingList, IList, ICollection, IEnumerable, _ ITypedList |
Remarks
The steps for using the TableBindingAdapter are:
- Create a new TableBindingAdapter object passing in a reference to either a Table or a RowCollection. A Table object represents all the data stored in the Table whereas a RowCollection usually represents a subset of rows, for example only the rows returned from a Search or a SearchByDistance query.
- Specify whether column headings should display alias names (UseColumnAliasNames).
- Specify whether to display the raw values or coded domain values any Column using a CodedValueDomain.
- Use the Fill method to populate the TableBindingAdapter. The Fill method is overloaded so that you can optionally load rows by ObjectID.
- Set the TableBindingAdapter object as the DataSource or BindingSource to a .NET Control.
When a TableBindingAdapter is bound to a .NET DataGridView control you can sort the grid by simply clicking on a column heading. The recommended approach to sorting data programmatically is as follows:
- Where no user interaction is required then use the Sort method before loading the data into the TableBindingAdapter.
- Where the user can interact with the .NET Control and additionally needs to be able to sort on multiple columns then you need to implement this in the control itself.
You can use the GetRelatedBindingAdapter method to create a TableBindingAdapter object which represents the rows which are related to the selected row or rows in the current TableBindingAdapter instance. This is useful for displaying hierarchical data, such as a one-to-one or one-to-many TableRelationship between two Table objects.
The TableBindingAdapter implements five .NET interfaces to provide the functionality that allows a Table to be bound to a .NET control. However, it should be noted that many of the properties and methods on these interfaces are currently either not implemented or only partially implemented.
The TableBindingAdapter does not currently support caching, so you are likely to experience poor performance or possibly a crash if you try to load a large Table.
Examples
{ //Open the mountains fill geodatabase feature class Table mountains = Table.OpenFileGeodatabaseTable(@"C:\Data\Scotland.gdb", "mountains"); //Create a new TableBindingAdapter object for the mountains Table TableBindingAdapter tableAdapter = new TableBindingAdapter(mountains); //Fill the adapter with all the rows from the mountains Table tableAdapter.Fill(); //Set the UseCodedValueDomains property to display the descriptive name for the values in any //columns which have a CodedValueDomainDefined tableAdapter.UseCodedValueDomains = true; //Set the UseColumnAliasNames property to display alias names in the Column headers. tableAdapter.UseColumnAliasNames = true; //Note that the BindingSource component and the DataGridView control would normally be //instantiated by dragging and dropping them onto a Windows Form from the toolbox. //Create a new BindingSource component System.Windows.Forms.BindingSource bindingSource1 = new System.Windows.Forms.BindingSource(); //Set the DataSource to be the tableAdapter object bindingSource1.DataSource = tableAdapter; //Create a DataGridView control System.Windows.Forms.DataGridView dataGridView1 = new System.Windows.Forms.DataGridView(); //Set the Datasource to be the bindingSource1 object dataGridView1.DataSource = bindingSource1; }
'Open the mountains file geodatabase feature class Dim mountainsTable As Table = Table.OpenFileGeodatabaseTable("C:\Data\Scotland.gdb", "mountains") 'Create a new TableBindingAdapter object for the mountains Table Dim tableAdapter As TableBindingAdapter = New TableBindingAdapter(mountainsTable) 'Set the UseCodedValueDomains property to display the descriptive name for the values in any 'columns which have a CodedValueDomainDefined tableAdapter.UseCodedValueDomains = True 'Set the UseColumnAliasNames property to display alias names in the Column headers. tableAdapter.UseColumnAliasNames = True 'Fill the adapter with all the rows from the mountains Table tableAdapter.Fill() 'Note that the BindingSource component and the DataGridView control would normally be 'instantiated by dragging and dropping them onto a Windows Form from the toolbox. 'Create a new BindingSource component Dim bindingSource1 As System.Windows.Forms.BindingSource = New System.Windows.Forms.BindingSource() 'Set the DataSource to be the tableAdapter object bindingSource1.DataSource = tableAdapter 'Create a DataGridView control Dim dataGridView1 As System.Windows.Forms.DataGridView = New System.Windows.Forms.DataGridView() 'Set the Datasource to be the bindingSource1 object dataGridView1.DataSource = bindingSource1