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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DBGrid column width

Status
Not open for further replies.

rickgalty

Programmer
Nov 10, 2005
32
US
How can I set the width of individual coulmns at runtime? It seems to me that the line

dgRecords.Columns(1).Width = 2000

Should set the width of the second column to 2000 pixels, but it has no effect at all. I have DefColWidth set to 0 in the design time properties window.

As a follow up, is there a way to put a check box into a cell of a DBGrid instead of it just showing 0 or -1 ?

Richard
 
There are checked and unchecked checkbox characters in character map. I've used them in a flexgrid and switched the characters to show a value. It's simple, but it works!

-David
2006 Microsoft Valued Professional (MVP)
 
Depends on when you do it. If you load the grid and then set the column width you will see it change. If you set the width(s) and then load data by setting the DataSource or RecordSource properties then the widths will be reset to the default width. The "refresh" and "requery" methods also reset the column widths.

Check out HoldFields for one method of preserving column widths.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top