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

10.4 Virtual Grid

Objective Grid for Microsoft .NET includes a sample virtual grid application. It is in the Samples subdirectory and is named Virtual Grid. The following steps explain how to create this project.

10.4.1 Create a solution for the virtual grid project

  1. Start Visual Studio .NET.

  2. From the File menu, select File | New | Project.

  3. In the Project Types dialog, select Visual C# Projects.

  4. Click OK to create the project. The Visual Studio .NET project wizard generates a project template according to your settings.

10.4.2 Place a GridControl on Form1.cs.

  1. Select the View | Solution Explorer menu option to view the Solution Explorer.

  2. In Solution Explorer, double-click Form1.cs to view the form in design mode.

  3. Size the form as desired.

  4. Select the View | Toolbox menu option to view the Windows Forms controls toolbox.

  5. Drag a GridControl from the Toolbox onto the form.

  6. Size the GridControl to fill the form.

  7. With the GridControl selected in the form, set the following GridControl properties.

10.4.3 Create a Data Structure for Storing Grid Cell Values

The class is implemented using a hash table, which hashes the cell values based on the row and column coordinates for the cell. The class implements ISerializable, so that it can be persisted. An indexer makes access to the grid data from our grid application more convenient.

  1. Select the View | Class View menu option to view the class view for the project.

  2. Right-click Virtual Grid project name, and then select Add | Add Class from the context menu.

  3. In the C# Class Wizard:

  4. View the code for DataArray.cs. If it did not appear after you clicked Finish, double click DataArray.cs in the Solution Explorer, and then select the View | Code menu option.

  5. Change the DataArray class definition so that it implements ISerializable:

  6. At the top of the source file, add using declarations for System.Collections and System.Runtime.Serialization:

  7. Add a private hash table data member to store the grid data:

  8. Add code for an indexer to access the cell data by row and column indexes:

    The hash table key and value types are both .NET String instances. Only the cell values are hashed. The key is formatted using the row and column offsets. For example, the key for cell 1, 1 is String(1,1).

  9. The following two methods implement serialization for the grid cell data:

  10. The completed DataArray class should look something like the following:

10.4.4 Add Virtual Grid Support to the Project

  1. Add following using declarations:

  2. Add a main menu for your application:

  3. Add member variables for storing your data:

  4. Add constructor code to load open, and load the DataArray containing the grid data:

10.4.5 Add Event Handlers for the Menu Commands and Virtual Grid Events

  1. View Form1.cs in design view.

  2. Select the GridControl in the designer by either selecting gridControl1 in the Properties list or by clicking any cell in the grid.

  3. Click the lightening bolt in the grid properties window to view the Objective Grid for Microsoft .NET events.

  4. Double-click the GetStyleRowCol event.

  5. Add the following event handling code for the event:

  6. View Form1.cs in design view.

  7. Double-click the StoreStyleRowCol event.

  8. Add the following event handling code for the event:

  9. View Form1.cs in design view.

  10. Click the File menu.

  11. Double-click the Save menu option.

  12. Add the following event handling code for this menu option:

  13. View Form1.cs in design view.

  14. Click the File menu.

  15. Double-click the Exit menu option.

  16. Add the following event handling code for this menu option:

  17. Compile and run your virtual grid application.



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.