HELP :Setting Column width in a DBGrid ? 
Author Message
 HELP :Setting Column width in a DBGrid ?

I am trying to set the column widths in DBGrid1

The first 3 field columns in my DBGrid1 need to be only 4 or 5 chars.
wide.
I would like to set them with code, so they are the correct width when
I run the program, rather than adjust them after I start the program.

Any help as to how/where this is to be done would be greatly
appreciated.

TKS
Bill Dannels  (NewBee)

Private Sub cmdFindCustNo_Click()
Sqlcode2 = "SELECT ORDERS.CUSTNO, ORDERS.DATE, ORDERS.PLANTORNU,
CUSTOMER.NAME," _
& " ORDERS.QUANITY, ORDERS.WSize, ORDERS.LSize, ORDERS.Each,
ORDERS.PricePerM" _
& " FROM CUSTOMER INNER JOIN ORDERS ON CUSTOMER.CUSTNO =
ORDERS.CUSTNO" _
& " WHERE CUSTOMER.CUSTNO =" & txtFindCustNo
Data1.RecordSource = Sqlcode2
Data1.Refresh

End Sub



Tue, 13 Feb 2001 03:00:00 GMT  
 HELP :Setting Column width in a DBGrid ?
DBGrid1.Columns(0).Width=nnn
DBGrid1.Refresh.

The same for Columns(1) and (2). You might find 750 or thereabouts will hold
5 chars as a setting, depending on your Scale. You'll get truncated column
headings if you have them turned on, though you can alias these.

Put in after the Data1 settings.

PS - if your CUSTNO field really is Text, you'll need to put double quotes
around the variable in the query; I use "... WHERE CUSTOMER.CUSTNO = " &
Chr(34) & txtFindCustno & Chr(34)

Quote:

>I am trying to set the column widths in DBGrid1

>The first 3 field columns in my DBGrid1 need to be only 4 or 5 chars.
>wide.
>I would like to set them with code, so they are the correct width when
>I run the program, rather than adjust them after I start the program.

>Any help as to how/where this is to be done would be greatly
>appreciated.

>TKS
>Bill Dannels  (NewBee)

>Private Sub cmdFindCustNo_Click()
>Sqlcode2 = "SELECT ORDERS.CUSTNO, ORDERS.DATE, ORDERS.PLANTORNU,
>CUSTOMER.NAME," _
>& " ORDERS.QUANITY, ORDERS.WSize, ORDERS.LSize, ORDERS.Each,
>ORDERS.PricePerM" _
>& " FROM CUSTOMER INNER JOIN ORDERS ON CUSTOMER.CUSTNO =
>ORDERS.CUSTNO" _
>& " WHERE CUSTOMER.CUSTNO =" & txtFindCustNo
>Data1.RecordSource = Sqlcode2
>Data1.Refresh

>End Sub



Wed, 14 Feb 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Setting datagrid column width sets width of toplevel!!

2. set column width in dbgrid

3. How to set Column width in DBGrid ?

4. DBGrid column width setting

5. DBGrid and Setting Column Widths at design time

6. DbGrid, Setting Column Widths

7. Syntax for setting column widths in DbGrid

8. Make dbgrid columns width follow form width ???

9. Set Grid width to sum of Column Widths

10. Need Help - DBGRID column width

11. How to resize the column width in DBGrid?

12. DBGrid control and column widths

 

 
Powered by phpBB® Forum Software