How to Clear All or Part of Grid in Visual BasicLast reviewed: June 21, 1995Article ID: Q88911 |
The information in this article applies to:
SUMMARYYou can clear all or part of a grid by first selecting the region to clear using the SelStartCol, SelStartRow, SelEndCol, and SelEndRow properties, and then clearing the region by assigning a null string to the Clip property.
MORE INFORMATIONThe example below demonstrates how to clear all the non-fixed cells of a grid.
Step-by-Step Example1. Start Visual Basic or from the File menu, choose New Project (ALT, F, N)if Visual Basic is already running. Form1 is created by default.
Sub Form_Load () ' Load some data into the grid. For i% = Grid1.FixedCols To Grid1.Cols - 1 For j% = Grid1.FixedRows To Grid1.Rows - 1 Grid1.Col = i% Grid1.Row = j% Grid1.Text = Format$(i% + j%) Next Next End Sub
Sub Form_Click () ' Select all non-fixed grid cells. Grid1.SelStartCol = Grid1.FixedCols Grid1.SelStartRow = Grid1.FixedRows Grid1.SelEndCol = Grid1.Cols - 1 Grid1.SelEndRow = Grid1.Rows - 1 ' Clear the cells. Grid1.Clip = "" ' Clean up the grid. Grid1.Col = Grid1.FixedCols Grid1.Row = Grid1.FixedRows Grid1.SelEndCol = Grid1.SelStartCol Grid1.SelEndRow = Grid1.SelStartRow End Sub
|
Additional reference words: 1.00 2.00 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |