The MSFlexGrid control provides a great way to display records in
multiple rows and columns. Often, however, you may want to display a variable number of rows or colums based on selections from the user.
As a result you'll need a way to quickly clear not just the contents of the extraneous rows, but also to reduce the number of rows in the
control. For instance, if the MSFlexGrid currently displayed 15 rows, and the user chooses to display only 10 at runtime, you need to delete
five extra rows.
To do so, you might think to loop backwards through the rows and execute the RemoveItem method on each row. However, if you have a large number
of rows to delete, using a For/Next loop could take some serious time and hang your application.
As an alternative, you can simply reduce the number of rows by resetting the control's Rows property. Normally, this property returns the total
number of rows in the grid. However, you can also use it to remove rows.
For instance, if your flexgrid currently contained 15 rows, and you
wanted to reduce them to 10, you could simply issue the following code
statement:
MSFlexGrid1.Rows = 9
Don't forget that flexgrid rows start with 0. The above example assumes that you haven't placed a header in the very first row. If so, then you
could set the Rows property to 10 instead of 9 to display ten data rows. You can use the flexgrid's Cols property to delete columns in a similar
manner.
Empty the MSFlexGrid
By ElementK Journals, published on 14 Jul 2001
| Filed in
You might also like...
VB 6 forum discussion
-
CorelDRAW VBA: cdrTraceLineDrawing FAILS, producing single linear path instead of Centerline trace?
by dancemanj (0 replies)
-
client/server application using activex
by beautifulheart (0 replies)
-
System Error &H8007007E. The specifed module could not be found.
by swiftsafe (5 replies)
-
Invitation to take part in an academic research study
by researchlab (0 replies)
-
Send SMS with SMPP
by mmahmoud (0 replies)
VB 6 podcasts
-
Stack Overflow Podcast: Podcast #45 – Keeping it Sharp
Published 7 years ago, running time 0h54m
Our guest this week is Eric Lippert – language architect extraordinaire and famous for all his work at Microsoft in developing their languages Eric joined Microsoft right out of college and was originally working on VB It’s time for everyone’s favorite game: Name the Worst Feature of that Microso.
Comments