Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am trying to get the data contained in a database to appear in a list box on a form in VB, I have no problem getting the data to appear eg.
ProductNo
Manufacturer
Product Line
etcone after the other vertically but I want the data to appear horizontally eg.
Product No Manufacturer Product Line etc.
I am using data control to retrieve the data to the form.
How do I get the data to display as I would like? Also I would like for there to be vertical lines separating each field item to give the effect columns in the listbox display.
Thanking you
Regards
M

You need you use one of the Grid controls. Either the MSFelx Grid or the DataGrid.
These allow you to display the Data in a similar fashion to a spreadsheet.
Do do what you want with a List Box is possible but cumbersome. The Grid controls are the right tool for the job.
Stuart

Thanks Stuart,
For the prototype I have to build, prior to the actual project which I intend to use Access forms MSFlexGrid will do brilliantly providing I can specify what is to be displayed, the test I ran displayed all fields & I could not find how to alter this. Also is there a way to change the size of the cells, my data is not fully displayed?
I liked the look of the data grid as it looked more flexible but I could not get data to display, I set the data control and data source etc but nothing, I also had a go with list grid but this only displayed the first field no matter what field I selected.
I have looked in all my books but no mention of the above functions and before I venture into the depths of VB Help have you a basic english tutorial you could give if only on how to make the flex grid flex? as I have a feeling the data grids are going to be involved.
Thanks again
Regards
M

>> before I venture into the depths of VB Help <<
Thats the first thing to do, it full of useful information. The VB Help gives you all the information you need and some good examples.
Chenge the width of coeels with the CollWidth Property. There are two ways of deciding which fields are displyed. Either only axtract the rquired fileds with the SQL statement, or itereate through the recordset and fill the Grid under your control.
The list control will only ever display one field - thats all its meant to do without a lot of manipulation.
Stuart

Plain lazyness, my main PC's processor fan broke today and I can't locate the CD ROM drive for my laptop etc etc. Thanks for the reply I have managed to suss DataGrid enough to do the job and looking at how relatively simple it was I may now build a front end using VB6.
Regards
M

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |