Solved

clearing a grid control

Posted on 1998-09-21
6
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

691 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