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
Solved

clearing a grid control

Posted on 1998-09-21
6
227 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

840 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