How to Hide a Column From FlexGrid in Visual Basic 6

Written by brian kim
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Hide a Column From FlexGrid in Visual Basic 6
One of the neat features provided by the VS FlexGrid control is the ability to hide columns of data. (the programmer and a computer image by Andrey Andreev from Fotolia.com)

Although Visual Basic 6 (VB6) has been superseded by the Visual Basic.Net series of programming packages, VB6 still has a large following. Part of the reason for this is because VB6 is easier to use than its .Net counterpart and has garnered a wide range of useful add-on tools. One of these tools is the FlexGrid control, originally from VideoSoft (VS). This add-on provides powerful spreadsheet-like functionalities to VB6 in an easy-to-use package. One of the neat features provided by the VS FlexGrid control is the ability to hide columns of data.

Skill level:
Moderate

Other People Are Reading

Instructions

  1. 1

    Start VB6 and modify the pre-created Form (user interface window) to your liking. Using the mouse and the properties pane on the lower right side, you can change all aspects of the Form such as the size, title and colours.

  2. 2

    Load the VS FlexGrid control. From the "Project" menu, click on "Components." You will see a dialogue box with several tabs. Choose the "Controls" tab, and a listing of several "Videosoft" products will appear, including one for "VSFlexGrid." Select this control (put a check in the box next to it) and press the "OK" button. You should now see a new icon in the controls tool strip on the left side.

  3. 3

    Select the new icon and draw a suitable grid on your Form. In the lower-right pane, change the name of the grid to "VS." Then right-click on the grid and select "Properties" from the pop-up menu. You will be presented with a dialogue box with several tabs containing various properties (e.g., colour) of the grid. Change any of these properties to your liking.

  4. 4

    For testing purposes, create some text headers for each column on the grid. This can be accomplished by double-clicking on the Form (anywhere but on the grid). You will be taken to a coding window where you can specify code to be run. Your cursor should appear inside of the appropriate subroutine section. Within this subroutine, type the following:

    VS.Row = 0

    VS.Col = 0

    VS.Text = "Car"

    VS.Col = 1

    VS.Text = "Ship"

    VS.Col = 2

    VS.Text = "Airplane"

  5. 5

    Go back to the Form window and create two buttons. You can do this by selecting the "CommandButton" icon (looks like a button) in the controls strip on the left side and then drawing the buttons on the Form. Using the properties pane on the bottom right side, change the caption of one button to "Hide" and the other to "Show."

  6. 6

    Double-click the button labelled, "Hide" and you will be taken to a coding window with the cursor within the appropriate subroutine. Type the following code in that subroutine:

    VS.ColHidden(1) = True

    Similarly, double-click the button labelled, "Show" and type in the following code in the new subroutine:

    VS.ColHidden(1) = False

  7. 7

    Test the program by pressing the play button (the sideways-pointing triangle) on the top horizontal toolbar. That should bring up the Form with the grid and the two buttons. You should see the first three fields of the grid labelled as "Car," "Ship" and "Airplane." When you press the "Hide" button, you should see the "Ship" column disappear. Press the "Show" button and you should see the column appear again.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.