ComponentOne True DBGrid for WinForms
True DBGrid for WinForms Task-Based Help / Resizing Columns During Grid Resizing
In This Topic
    Resizing Columns During Grid Resizing
    In This Topic

    To expand or shrink columns during grid resizing, set the SpringMode property to True and the MinWidth property for each column. This can be done either in the designer or in code.

    In the Designer

    To expand or shrink columns during grid resizing in the designer, complete the following steps:

    1. Open the C1TrueDBGrid Designer. For information on how to access the C1TrueDBGrid Designer, see Accessing the C1TrueDBGrid Designer.
    2. Click the Split tab in the left pane.
    3. Locate the SpringMode property and set it to True.
      Alternatively, the SpringMode property can also be in the Properties window.
    4. Select the First column in the right pane by clicking on it.
      The column can also be selected by choosing First from the drop-down list in the toolbar.
    5. Click the Display Column tab in the left pane.
    6. Locate the MinWidth property and set it to 50.
    7. Click OK to close the designer.

    In Code

    To expand or shrink columns during grid resizing in code, complete the following steps:

    1. Set the SpringMode property to True by adding the following code to the Form_Load event:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Me.C1TrueDBGrid1.SpringMode = True
      

      To write code in C#

      C#
      Copy Code
      this.c1TrueDBGrid1.SpringMode = true;
      
    2. Set the MinWidth property to 50 for the First column:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Me.C1TrueDBGrid1.Splits(0).DisplayColumns("First").MinWidth = 50
      

      To write code in C#

      C#
      Copy Code
      this.c1TrueDBGrid1.Splits[0].DisplayColumns["First"].MinWidth = 50;
      

    What You've Accomplished

    When the grid is resized horizontally, the columns will expand or shrink proportionally, except for the First column which will only shrink to 50: