Gets or sets the data source that the
Grid is displaying data for.
Namespace: Dapfor.Net.Ui
Assembly: Dapfor.Net (in Dapfor.Net.dll) Version: 2.10.3.24917 (2.10.3.24917)
Syntax
C# |
---|
public Object DataSource { get; set; } |
Visual Basic |
---|
Public Property DataSource As Object
Get
Set |
Visual C++ |
---|
public:
property Object^ DataSource {
Object^ get ();
void set (Object^ value);
} |
F# |
---|
member DataSource : Object with get, set
|
Property Value
Type:
ObjectThe data source. A type, implementing one of the next interfaces:
IList,
IListSource,
IBindingList
Examples
| Copy |
---|
public void SetDataSource(Grid grid)
{
DataTable table = new DataTable();
table.Columns.Add(new DataColumn("Column1"));
table.Columns.Add(new DataColumn("Column2"));
table.Rows.Add(new object[] { "Row0, Col0", "Row0, Col1" });
table.Rows.Add(new object[] { "Row1, Col0", "Row1, Col1" });
table.Rows.Add(new object[] { "Row2, Col0", "Row2, Col1" });
grid.Headers.AutoGenerate = true;
grid.DataSource = table;
Row row1 = grid.Rows[0];
Console.WriteLine("Row1, Column1: value = {0}", row1["Column1"].Value);
Console.WriteLine("Row1: index in Grid: {0}, index in Datasource = {1}", row1.VisibleIndex, row1.DataSourceIndex);
grid.Headers[0]["Column1"].SortDirection = SortDirection.Descending;
Console.WriteLine("Row1: index in Grid: {0}, index in Datasource = {1}", row1.VisibleIndex, row1.DataSourceIndex);
row1.Filtered = true;
Console.WriteLine("Row1: index in Grid: {0}, index in Datasource = {1}", row1.VisibleIndex, row1.DataSourceIndex);
Row row2 = grid.Rows[0];
Console.WriteLine("Row2: index in Grid: {0}, index in Datasource = {1}", row2.VisibleIndex, row2.DataSourceIndex);
Console.WriteLine("Row2, Column1: value = {0}", row2["Column1"].Value);
}
Output:
Row1, Column1: value = Row0, Col0
Row1: index in Grid: 0, index in Datasource = 0
Row1: index in Grid: 2, index in Datasource = 0
Row1: index in Grid: -1, index in Datasource = 0
Row2: index in Grid: 0, index in Datasource = 2
Row2, Column1: value = Row2, Col0 |
See Also