In code, you must create and remove splits using the RemoveHorizontalSplit, InsertHorizontalSplit, RemoveVerticalSplit, and RemoveHorizontalSplit methods. Each method takes a zero-based split index:
Dim S As C1TrueDBGrid.Split
' Create a split with index 7.
Me.C1TrueDBGrid1.InsertVerticalSplit(7)
' Remove the split with index 5.
Me.C1TrueDBGrid1.RemoveVerticalSplit(5)
· C#
C1TrueDBGrid.Split S;
// Create a split with index 7.
this.C1TrueDBGrid1.InsertVerticalSplit(7);
// Remove the split with index 5.
this.C1TrueDBGrid1.RemoveVerticalSplit(5);
· Delphi
// Create a split with index 7.
Self.C1TrueDBGrid1.InsertVerticalSplit(7);
// Remove the split with index 5.
Self.C1TrueDBGrid1.RemoveVerticalSplit(5);
You can determine the number of splits in a grid using the SplitCollection Count property:
' Set variable equal to the number of splits in C1TrueDBGrid1.
variable = Me.C1TrueDBGrid1.Splits.Count
· C#
// Set variable equal to the number of splits in C1TrueDBGrid1.
variable = this.C1TrueDBGrid1.Splits.Count;
· Delphi
// Set variable equal to the number of splits in C1TrueDBGrid1.
variable := Self.C1TrueDBGrid1.Splits.Count;
You can iterate through all splits using the Count property, for example:
For n = 0 To Me.C1TrueDBGrid1.Splits.Count - 1
Debug.WriteLine (Me.C1TrueDBGrid1.Splits(n).Caption)
Next n
· C#
for ( n = 0 ; n < this.C1TrueDBGrid1.Splits.Count; n++)
{
Console.WriteLine (this.C1TrueDBGrid1.Splits[n].Caption);
}
· Delphi
for n := 0 To Self.C1TrueDBGrid1.Splits.Count – 1 do
Debug.WriteLine (Self.C1TrueDBGrid1.Splits(n).Caption);
Of course, a more efficient way to code this would be to use a For Each...Next loop:
Dim S As C1TrueDBGrid.Split
For Each S In Me.C1TrueDBGrid1.Splits
Debug.WriteLine (S.Caption)
Next
· C#
C1TrueDBGrid.Split S;
foreach ( S In this.C1TrueDBGrid1.Splits)
{
Console.WriteLine (S);
}
· Delphi
var
S: C1TrueDBGrid.Split;
i: Integer;
begin
for i := 0 to Self.C1TrueDBGrid1.Splits.Count-1 do
begin
S := C1TrueDBGrid1.Splits[i];
Debug.WriteLine(S.Caption);
end;
end;
The new Split object will inherit all of its properties from the last object in the collection.
Send comments about this topic to ComponentOne. Copyright © ComponentOne LLC. All rights reserved. |