-
Using ValueLists [Janus GridEX WinForms Control v3.5 for .NET]
A column in the GridEX control can have a look up list to replace ID's stored in a table for a name associated to that ID.
The CategoryID field will have a value list to display the Category name to the user while the control internally works with the CategoryID value. The ValueList object is used also as the source list of a dropdown list when Combo or DropDownList EditType is used.
1 - Add Categories table to JSNorthwindDataSet. To add a table to an existing DataSet, in the Data Sources window, click in the "Configure DataSet" wizard button and check the table you want to add in the dialog that appears.
2 - Build the application so you can see CategoriesTableAdapter component in the tool box.
3 - Drag CategoriesTableAdapter component from the toolbox and drop it into the form.
In Tutorial 3 project, you could see that we are calling the FillCategoriesValueList method in the Load event of the form.
To have a ValueList in a column you must:
4 - Set the HasValueList property of the column equal to True. This is necessary to be able to get a ValueList from the ValueList property of the column; otherwise the property will return null (nothing in Visual Basic)
5 - Get the ValueList object from the column:
GridEXValueListItemCollection ValueList = column.ValueList;
6 - Fill the ValueList. To fill a ValueList you have two options:
6.1 - Use the Add method for each value item.
ValueList.Add(1, "Text 1")
ValueList.Add(2, "Text 2")
6.2 - Use the PopulateValueList method if you already have a list of objects or a DataView. When using this method, you must specify the ValueMember and DisplayMember.
ValueList.PopulateValueList(
tableCategories.DefaultView,
"CategoryID",
"CategoryName")
7 -(optional)(recommended) Set the CompareTarget and DefaultGroupInterval properties of the column equal to Text. When you sort or group a column, the control by default uses the value it retrieves from its DataSource, setting these properties, you are instructing the control to sort using the replaced values (in this case, the control will sort category names instead of sorting the category id’s).
8 - (optional) set the EditType property of the column equal to Combo or DropDownList.
Source Of Information : Janus v3.5 Help Files for VS 2008
Subscribe to:
Post Comments (Atom)
0 comments: