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:
Other People Are Reading
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.
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.
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.
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"
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."
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
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.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for