Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I expand the DBGrid columns?

Status
Not open for further replies.

chongning

Programmer
Apr 30, 1999
2
0
0
US
The default columns for DBGrid (VB5) have only two columns. I need to add more columns to the Grid. How can I do it? Thanks
 
The Dbgrid changes the number of columns depending on the number of fields from the recordset. <br>

 
Hi, Hug: <br>
<br>
Thanks for your replay, I thought the same thing when I worked on VB4 with add-on Dbgrid. But, however, my program in VB5 would not do it. It only shows two columns from my access table which has about 50 fields ( I need five fields to display) Do you know how can I get round it?
 
If your DBGrid is bound to a data control and the database and recordsource properties are filled in just right click on the grid and select Retrieve Fields. This will pull all of the table fields onto your grid. If you don't want all of the fields set the Visible property for thoe columns to false by unchecking the visible box on the Layout tab of the properties box.<br>
<br>
If your grid is unbound you can use code to set the number of columns and column properties.<br>

 
It happened to me too once, I fixed just changed the columns property on the dbgrid and voila!.<br>
Check also the recorsource on the data control, the dbgrid bounds to the number of fields on the recorset at design.<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top