True DBGrid for WinForms | ComponentOne
Split Presentation / Size and Scale Split
In This Topic
    Size and Scale Split
    In This Topic

    True DBGrid for WinForms provides full control over the size and scaling of individual splits. Configure a split to occupy an exact width or height, hold a fixed number of columns or rows, or adjust its size proportionally in relation to other splits. When initially starting out with True DBGrid for WinForms controls, splits can still be used in a variety of ways without having to master all of the details.

    At run time, the actual size of a Split object depends upon its SplitSize and SplitSizeMode properties. The SplitSizeMode property specifies the unit of measurement; the SplitSize property specifies the number of units. True DBGrid for WinForms supports three different sizing modes for splits, as determined by the setting of the SplitSizeMode property:

    Mode Description
    SizeModeEnum.Scalable Denotes relative width in relation to other splits.
    SizeModeEnum.Exact Specifies a fixed width in container coordinates.
    SizeModeEnum.NumberofColumns Specifies a fixed number of columns.

    A scalable split uses the value of its SplitSize property to determine the percentage of space the split will occupy. For any scalable split, the percentage is determined by dividing its SplitSize value by the sum of the SplitSize values of all other scalable splits. Thus, consider the SplitSize property of a scalable split to be the numerator of a fraction, the denominator of which is the sum of the scalable split sizes. Scalable splits compete for the space remaining after nonscalable splits have been allocated. By default, all splits are scalable, so they compete for the entire grid display region. SplitSizeMode is always Scalable when a grid contains only one split.

    An exact split uses the value of its SplitSize property as its fixed width in container coordinates. Exact splits will be truncated if they will not fit within the horizontal grid boundaries. This mode is not applicable when a grid contains only one split.

    A fixed-column split uses the SplitSize property to indicate the exact number of columns that should always be displayed within the split. These splits automatically reconfigure the entire grid if the size of the displayed columns changes (either by code or user interaction), or if columns in the split are scrolled horizontally so that the widths of the displayed columns are different. This mode is primarily used to create fixed columns that do not scroll horizontally. However, it can be used for a variety of other purposes as well. This mode is not applicable when a grid contains only one split.

    Note that when there is only one split (the grid's default behavior), the split spans the entire width of the grid, the SplitSizeMode property is always Scalable, and the SplitSize property is always 1. Setting either of these properties has no effect when there is only one split. If there are multiple splits, and then remove all but one so the SplitSizeMode and SplitSize properties of the remaining split automatically revert to 0 and 1, respectively.

    By default, the SplitSizeMode property for a newly created split is SizeModeEnum.Scalable, and the SplitSize property is set to 1. For example, two additional splits can be created with the following code:

    C#
    Copy Code
    // Create a Split on the left.
    this.c1TrueDBGrid1.InsertHorizontalSplit(0);
    
    // Create another.
    this.c1TrueDBGrid1.InsertHorizontalSplit(0);
    

    The resulting grid display will appear as follows:

    Notice that each split occupies 1/3 of the total grid space. This is because there are three scalable splits, and each split has a SplitSize of 1. If the sizes of the splits are changed to 1, 2, and 3, respectively:

    C#
    Copy Code
    // Change relative size to 1.
    this.c1TrueDBGrid1.Splits[0].SplitSize = 1;
    
    // Change relative size to 2.
    this.c1TrueDBGrid1.Splits[1].SplitSize = 2;
    
    // Change relative size to 3.
    this.c1TrueDBGrid1.Splits[2].SplitSize = 3;
    

    The resulting grid display will appear as follows:

    Notice the sum of the split sizes (1+2+3) is 6, so the size of each split is a fraction with the numerator being the value of its SplitSize property and a denominator of 6.

    When a split's SplitSizeMode is set to SizeModeEnum.Exact, that split receives space before the other splits. This behavior is somewhat more complex, but understanding how scalable splits work is helpful. For example, assume that splits are set in the following way:

    C#
    Copy Code
    this.c1TrueDBGrid1.Splits[0].SplitSizeMode = C1.Win.C1TrueDBGrid.SizeModeEnum.Scalable;
    this.c1TrueDBGrid1.Splits[0].SplitSize = 1;
    
    this.c1TrueDBGrid1.Splits[1].SplitSizeMode = C1.Win.C1TrueDBGrid.SizeModeEnum.Exact;
    this.c1TrueDBGrid1.Splits[1].SplitSize = 250;
    
    this.c1TrueDBGrid1.Splits[2].SplitSizeMode = C1.Win.C1TrueDBGrid.SizeModeEnum.Scalable;
    this.c1TrueDBGrid1.Splits[2].SplitSize = 2;
    

    After configuring the splits in this way, the resulting grid display will look like this.

    The fixed-size split in the middle (Split1) is configured to exactly 250 pixels, and the remaining splits compete for the space remaining in the grid. Since the remaining splits are both scalable splits, they divide the remaining space among themselves according to the percentages calculated using their SplitSize property values. So, the leftmost split occupies 1/3 of the remaining space, and the rightmost split occupies 2/3.

    Splits with SplitSizeMode set to SizeModeEnum.NumberOfColumns behave almost identically to exact splits, except their size is determined by the width of an integral number of columns. The width, however, is dynamic, so resizing the columns or scrolling so that different columns are in view will cause the entire grid to reconfigure itself.

    Avoid creating a grid with no scalable splits. Although True DBGrid for WinForms handles this situation, it is difficult to work with a grid configured in this way. For example, if no splits are scalable, all splits will have an exact size, which may not fill the entire horizontal width of the grid. If the total width of the splits is too short, True DBGrid for WinForms displays a "null-zone" where there are no splits. If the total width of the splits is wider than the grid, then True DBGrid for WinForms will show only the separator lines for the splits that cannot be shown.