[]
        
(Showing Draft Content)

C1.Win.FlexGrid.MultiColumnDictionary

MultiColumnDictionary Class

Class that implements the IC1MultiColumnDictionary and can be used as a column DataMap to create multi-column combo editors.

Inheritance
MultiColumnDictionary
Namespace: C1.Win.FlexGrid
Assembly: C1.Win.FlexGrid.8.dll
Syntax
public class MultiColumnDictionary : ListDictionary, IC1MultiColumnDictionary2, IC1MultiColumnDictionary, IDictionary, ICollection, IEnumerable
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.

Examples

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

// 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;

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:

// 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;

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.

Constructors

Name Description
MultiColumnDictionary(ITypedList, string)

Initializes a new instance of a bound MultiColumnDictionary class.

MultiColumnDictionary(ITypedList, string, string[], int)

Initializes a new instance of a bound MultiColumnDictionary class.

MultiColumnDictionary(DataTable, string)

Initializes a new instance of a bound MultiColumnDictionary class.

MultiColumnDictionary(DataTable, string, string[], int)

Initializes a new instance of a bound MultiColumnDictionary class.

MultiColumnDictionary(string)

Initializes a new instance of an unbound MultiColumnDictionary class.

MultiColumnDictionary(string, int, bool)

Initializes a new instance of an unbound MultiColumnDictionary class.

Properties

Name Description
this[object]

Gets or sets the value associated with the specified key

Methods

Name Description
Add(object, object)

Adds an entry with the specified key and value into the MultiColumnDictionary.

Clear()

Removes all entries from the MultiColumnDictionary.

GetColumnValue(object, int)

Gets the string which is in given column of the dictionary.