Solved

clearing a grid control

Posted on 1998-09-21
6
225 Views
Last Modified: 2010-04-30
What is the simplest way to clear a grid control of all it's data?

Code please...

Thanks
0
Comment
Question by:dtucker
  • 4
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
khaledc earned 100 total points
ID: 1435962
It is simply doing the following:
If your Grid Control is called Grid1 then all you have to do to clear it is:
Grid1.Clear
0
 

Author Comment

by:dtucker
ID: 1435963
Clear is not an option with the Grid control.
Clear is for listboxes, comboboxes and the clipboard.

0
 
LVL 1

Expert Comment

by:khaledc
ID: 1435964
What are you using? VB4 or VB5 and which Grid you are using ?
For MSGrid, there is definitely a "Clear" Property in VB5.

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:dtucker
ID: 1435965
I am using VB4-16bit, and it's just the plain old GRID control.
But I was able to get the code I needed from the sample loan app. that comes with VB4.

0
 
LVL 1

Expert Comment

by:khaledc
ID: 1435966
dtucker,
I will send a sample code to clear the grid in VB4, give a bit of time.
Regards
0
 
LVL 1

Expert Comment

by:khaledc
ID: 1435967
OK,
Suppose your Grid is called Grid1 then the code to clear the whole grid is as follows:
First, Get the number of rows and columns in your grid, you can do that as followed:
Dim intNumberOfRow as integer
Dim intNumnberOfCol as integer
dim i as integer
dim j as integer
     intNumberOfRow = grid1.cols    'Note Cols property is different from col property
     intNumberOfCol = grid1.rows    ' Note Rows property is different from row property

Second, clear every box as a time:

    for i = 0 to (intNumberOfCol-1)        'Numbering of rows and cols start from 0 and not 1
        for j = 0 to (intNumberOfRow-1)
             Grid1.row = j         'set which row has the attention
             Grid1.col = i          'set which column has the attention
             Grid1.text = ""
        next j
    next i

I hope this answered you question and that your points did not go to waste.
If you still need help on this matter, give me a yell
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now