-
Binding GridEX control at run time [Janus GridEX WinForms Control v3.5 for .NET]
To bind GridEX control at runtime, instead of using DataSource and DataMember properties you must use SetDataBinding method.
Once the control is bound you must call the RetrieveStructure method in order to force the control to create the table(s) and fields defined in the data source.
In VB:
'binding control at runtime
'First, get the table you want to bind to the control and populate it
'in this sample we create a table in memory but
'you can also create a table
'using OleDBConnection and OleDBDataAdapter object
Dim myTable As DataTable = New DataTable("GridEXTest")
'creating the columns in the table
myTable.Columns.Add("Number", GetType(Integer))
myTable.Columns.Add("Text", GetType(String))
myTable.Columns.Add("Date", GetType(DateTime))
'adding rows
myTable.Rows.Add(1, "Text 1", DateTime.Today)
myTable.Rows.Add(2, "Text 2", DateTime.Today)
myTable.Rows.Add(3, "Text 3", DateTime.Today)
'call SetDataBinding method to bind the control at run time
'and be able to set DataSource and DataMember properties
'at the same time
GridEX1.SetDataBinding(myTable, "")
'Once the control is bound, call Retrieve Structure method
'to force the control to create the table(s) and column(s)
'defined in the DataSource
GridEX1.RetrieveStructure()
In C#:
Source Of Information : Janus v3.5 Help Files for VS 2008
//binding control at runtime
//First, get the table you want to bind to the control
//and populate it.
//In this sample we create a table in memory but
//you can also create a table
//using OleDBConnection and OleDBDataAdapter object
DataTable myTable = new DataTable("GridEXTest");
//creating the columns in the table
myTable.Columns.Add("Number", typeof(int));
myTable.Columns.Add("Text", typeof(string));
myTable.Columns.Add("Date", typeof(DateTime));
//adding rows
myTable.Rows.Add(1, "Text 1", DateTime.Today);
myTable.Rows.Add(2, "Text 2", DateTime.Today);
myTable.Rows.Add(3, "Text 3", DateTime.Today);
//call SetDataBinding method to bind the control at run time
//and be able to set DataSource and DataMember properties
//at the same time
gridEX1.SetDataBinding(myTable, "");
//Once the control is bound, call Retrieve Structure method
//to force the control to create the table(s) and column(s)
//defined in the DataSource
gridEX1.RetrieveStructure();
Subscribe to:
Post Comments (Atom)
0 comments: