ComponentOne GridView for ASP.NET WebForms
Task-Based Help / Formatting the Grid's Content / Creating a Non Scrollable Row or Column
In This Topic
    Creating a Non Scrollable Row or Column
    In This Topic

    You can use the StaticRowIndex or StaticColumnIndex to freeze a row/column in order to prevent it from scrolling. An integer value to determine the row/column number to be frozen is set in this property.

    The following example fixes the first row in the grid so that it will not scroll.

    In the Designer

    Complete the following steps:

    1. Create a scrollable grid. See Creating a Scrollable Grid for further details.
    2. Right click the grid and choose Properties to view the associated properties and events of the C1GridView.
    3. Set the StaticRowIndex property to the index value of the row that has to be frozen.
    4. Click OK to save the setting and close the properties dialog.

    In Source View

    Complete the following steps:

    1. Create a scrollable grid. See Creating a Scrollable Grid for further details.
    2. Switch to Source view.
    3. Set the StaticRowIndex property of C1GridView to the index value of the column to be frozen by adding StaticRowIndex='0’ to the <cc1: C1GridView> tag as shown below:
    <cc1:C1GridView ID="C1GridView1" runat="server" StaticRowIndex='0'>
    

    This keeps the first row fixed when the grid is scrolled vertically.

    In Code

    Complete the following steps:

    1. Create a scrollable grid. See Creating a Scrollable Grid for further details.
    2. Set the first column's StaticRowIndex property to 0. This keeps the first row fixed when the grid is scrolled vertically.

      To write the code in Visual Basic:

        
      Visual Basic
      Copy Code
      ' Fix the top row of the grid when scrolling vertically.

       Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
           C1GridView1.StaticRowIndex = 0
       End Sub

      To write the code in C#:

      C#
      Copy Code
      // Fix the top row of the grid when scrolling vertically.

      protected void Page_Load(object sender, EventArgs e)

      {>

      C1GridView1.StaticRowIndex = 0;

      >}

    Run your application and scroll the grid. Note that the first row does not scroll with the other rows of the grid.

    Follow the same process using the StaticColumnIndex property to create non-scrollable columns.

    See Also