Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Grid for Microsoft .NET User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

3.4 Columns and Rows

This section shows you how to insert new rows and columns, remove rows and columns, hide rows and columns, and freeze rows and columns.


The RowsColumns_CS tutorial, which is located in the Tutorials subdirectory of your Objective Grid for Microsoft .NET installation directory, shows how to hide and freeze rows and columns.

Replace the code in FormLoad() with the following code:

Build and run the application.

Figure 15: Adding Rows and Columns In Code

3.4.1 Task 1: Inserting New Rows and Columns

The insertion of a new row or column moves the existing row or column. For example, if you want to add a new row between rows 3 and 4, you specify row 4 as the insertion point. The current row 4 becomes the new row 5.

  1. Add the following code to the LoadForm() method:

      // Insert a new row between rows 3 and 4 
      gridControl1.InsertRows( 4, 1 );
      
  2. Build and run the application.

    Figure 16: Inserting a Row

  3. Add the following code to the LoadForm() method:

  4. Build and run the application.

    Figure 17: Inserting Columns

3.4.2 Task 2: Removing Rows and Columns

Removing rows or columns is similar to inserting them. Add the following code to the LoadForm() method:

Build and run the application.

Figure 18: Removing Rows and Columns

3.4.3 Task 3: Hiding Rows and Columns

Hiding columns prevents them from being displayed.

  1. Add the following code to the LoadForm() method:

      // Hide row 1, and column 3
      gridControl1.HideRows( 1, 1, true );
      gridControl1.HideCols( 3, 3, true );
      
  2. Build and run the application.

    Figure 19: Hiding Rows and Columns

    Hidden rows and columns can be made visible again by passing false to the HideRows() and HideCols() methods.

  3. An entire range of rows and columns can be hidden by using the Range class. To illustrate this, set each cell's value to indicate its coordinate within the grid by adding the following code:

  4. Build and run the application.

    Figure 20: All Cells Visible

  5. Add code to hide cells B2 through D4:

    Figure 21: A Hidden Range

3.4.4 Task 4: Freezing Rows and Columns

When rows or columns are frozen, they do not scroll with the rest of the grid.

Replace the FormLoad() method with the following code:

Figure 22 shows the state of the grid after scrolling over several columns. The first three columns remain fixed, but the fourth and succeeding columns numbers increase.

Figure 22: Grid With Frozen Columns



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.