To create and add an object to a collection, use the collection's Add method. The method takes an object as its only argument. For example, create more valueitems for a column by adding new ValueItem objects to the ValueItemCollection object:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
' Create a ValueItem object. Dim v As C1TrueDBGrid.ValueItem = new C1TrueDbGrid.ValueItem() Me.C1TrueDBGrid1.Columns(0).ValueItems.Values.Add(v) |
To write code in C#
C# |
Copy Code
|
---|---|
// Create a ValueItem object. C1TrueDBGrid.ValueItem v = new C1TrueDBGrid.ValueItem(); this.c1TrueDBGrid1.Columns[0].ValueItems.Values.Add(v); |
This code adds a ValueItem object to the ValueItemCollection of C1TrueDBGrid1. Alternatively, create a ValueItem object with index 1 with the Insert method:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
' Create a Split object with index 1. Dim S As C1TrueDBGrid.ValueItem Me.C1TrueDBGrid1.Columns(0).ValueItems.Values.Insert(1, S) |
To write code in C#
C# |
Copy Code
|
---|---|
// Create a Split object with index 1. C1TrueDBGrid.ValueItem S; this.c1TrueDBGrid1.Columns[0].ValueItems.Values.Insert(1, S); |
The only object that is unable to add or remove members using the Add or RemoveAt methods is the Split object. InsertHorizontalSplit / RemoveHorizontalSplit and InsertVerticalSplit / RemoveVerticalSplit methods of the split object must be used to correctly add or remove Splits. These methods are also available in the grid's right-click context menu at design time.