True DBGrid for WinForms | ComponentOne
Scrollbar / Horizontal Scroll
In This Topic
    Horizontal Scroll
    In This Topic

    Scrolling is independent for each split. Often, one or more columns need to be prevented from scrolling horizontally or vertically so that the columns will always be in view. The True DBGrid offers an easy way to keep any number of columns from scrolling at any location within the grid by setting a few split properties.

    As an example, for a grid with three horizontal splits, the following code will "fix" columns 0 and 1 in the middle split:

    C#
    Copy Code
     // Hide all columns in Splits[1] except for columns 0 and 1.
     C1DisplayColumnCollection Column;
    Column = this.c1TrueDBGrid1.Splits[1].DisplayColumns;
    foreach (C1DisplayColumn C in Column)
     {
         C.Visible = false;
     }
     Column[0].Visible = true;
     Column[1].Visible = true;
    

    Usually, if columns 0 and 1 are kept from scrolling in one split, it will be desirable to have them invisible in the other splits:

    C#
    Copy Code
    // Make columns 0 and 1 invisible in splits 0 and 2.
    C1DisplayColumnCollection Cols;
    Cols = this.c1TrueDBGrid1.Splits[0].DisplayColumns;
    Cols[0].Visible = false;
    Cols[1].Visible = false;
    Cols = this.c1TrueDBGrid1.Splits[2].DisplayColumns;
    Cols[0].Visible = false;
    Cols[1].Visible = false;