ComponentOne GridView for ASP.NET WebForms
Task-Based Help / Setting Column Width
In This Topic
    Setting Column Width
    In This Topic

    This topic demonstrates how to set the width of a column in C1GridView.

    A column's width can be specified in code if the column is not automatically generated. To set the column width:

    1. Set the C1GridView.AutoGenerateColumns property of C1GridView to False.
    2. Specify the columns to appear in C1GridView. See Hiding Specified Columns for more information.
    3. Set the width of the third column, for example, via the Code Editor or at design time:
      • Add the following code after the DataBind method is called:

        To write the code in Visual Basic:

        Visual Basic
        Copy Code
        C1GridView1.Columns(2).ItemStyle.Width = New Unit(500)

        To write the code in C#:

          
        C#
        Copy Code
        C1GridView1.Columns[2].ItemStyle.Width = new Unit(500);
      • From the Property builder, select Format tab in the left pane and select a column from the list of Columns on the right. Change the Width property to 500 Pixels, and click OK.
      • OR
      • Edit the column's markup to include a Width element:
      • wijmo:C1BoundField DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName" Width="500">              
        

    What You've Accomplished

    In this topic you learned how to change the width of a column. In this example, the third column is 500 pixels: