Solved

clearing a grid control

Posted on 1998-09-21
6
228 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

726 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