FlexGrid for WinForms
MultiColumnDictionary Class
Members  Example 



Class that implements the IC1MultiColumnDictionary and can be used as a column DataMap to create multi-column combo editors.
Syntax
Remarks
The MultiColumnDictionary class can be used to implement simple string-based data maps or bound data maps that get the data from a data source object.
Example

The code below creates an unbound two-column data map and assigns it to a grid column:

The map consists of three items, each with two columns. Because the autoKeys parameter was set to true in the map's constructor, the map will have unique integer keys for each value,and those integers will be stored in the grid cells. If autoKeys had been set to false, the strings themselves would be used as keys and stored in the grid cells.

The code below creates a bound data map and assigns it to a grid column:

This map is bound to an Employees DataTable. The keyColumn parameter is set to "EmployeeID", causing this field to be used as a key. When the grid is edited, the values stored in the cells will be the employee's ID. However, this value is never displayed be the grid.

The drop-down list will show the employee's first name, last name, and country, as specified by the columnNames parameter.

When the list is closed, the grid will display the employee's last name, as specified by the displayColumn parameter.

Note that this map is dynamically bound to the data source, so if the employees table is modified, the editor list will reflect the changes automatically.

Note also that the usual combo editing features such as auto-search and double-click cycling still work.

// create string-based MultiColumnDictionary and assign it to column
// note: this will automatically generate keys of type 'int' for each item,
// the key values will be stored in the grid.
string text = "Row1, Col1\tRow1, Col2|Row2, Col1\tRow2, Col3|Row2, Col1\tRow3, Col2";
MultiColumnDictionary map = new MultiColumnDictionary(text, 0, true);
_flex.Cols[1].DataMap = map;
// create data-based MultiColumnDictionary and assign it to column
// notes: the list will automatically be updated is the data source changes.
DataTable dt = GetDataTable("employees");
string[] columnNames = new string[] { "FirstName", "LastName", "Country" };
MultiColumnDictionary map = new MultiColumnDictionary(dt, "EmployeeID", columnNames, 1);
_flex.Cols[2].DataMap = map;
Inheritance Hierarchy

System.Object
   System.Collections.Specialized.ListDictionary
      C1.Win.C1FlexGrid.MultiColumnDictionary

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

MultiColumnDictionary Members
C1.Win.C1FlexGrid Namespace

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Send Feedback