ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   vbAccelerator sGrid control- spacing columns. (https://www.excelbanter.com/excel-programming/285736-vbaccelerator-sgrid-control-spacing-columns.html)

Julian Milano[_2_]

vbAccelerator sGrid control- spacing columns.
 
Is there a forum or something dedicated to vbAccelerator controls?

I have a grid placed on an XL VBA userform, and was wondering how would I
set the width of the two columns, equally, upon startup. This is my code so
far:

Private Sub UserForm_Initialize()

With grdTransCalc
.Header = True
.AddColumn vKey:="TOTAL", sHeader:="Total",
ealign:=ecgHdrTextALignCentre
.AddColumn vKey:="AMT", sHeader:="Amount",
ealign:=ecgHdrTextALignCentre
.AutoWidthColumn "TOTAL"
.AutoWidthColumn "AMT"
If .ColumnWidth("TOTAL") < 60 Then .ColumnWidth("TOTAL") = .Width /
2
If .ColumnWidth("AMT") < 60 Then .ColumnWidth("AMT") = .Width / 2

End With
End Sub

The above code doesn't space the columns correctly! Is there a better way?

--

Julian Milano




Norm Cook

vbAccelerator sGrid control- spacing columns.
 
It appears that the AutoWidthColumn sizes them to the length of the text.
Try this:

With vbalGrid1
.Header = True
.AddColumn "TOTAL", "TOTAL", ecgHdrTextALignCentre, , 60
.AddColumn "AMT", "AMT", ecgHdrTextALignCentre, , 60
' .AutoWidthColumn "TOTAL"
' .AutoWidthColumn "AMT"
End With

"Julian Milano" wrote in message
...
Is there a forum or something dedicated to vbAccelerator controls?

I have a grid placed on an XL VBA userform, and was wondering how would I
set the width of the two columns, equally, upon startup. This is my code

so
far:

Private Sub UserForm_Initialize()

With grdTransCalc
.Header = True
.AddColumn vKey:="TOTAL", sHeader:="Total",
ealign:=ecgHdrTextALignCentre
.AddColumn vKey:="AMT", sHeader:="Amount",
ealign:=ecgHdrTextALignCentre
.AutoWidthColumn "TOTAL"
.AutoWidthColumn "AMT"
If .ColumnWidth("TOTAL") < 60 Then .ColumnWidth("TOTAL") = .Width

/
2
If .ColumnWidth("AMT") < 60 Then .ColumnWidth("AMT") = .Width / 2

End With
End Sub

The above code doesn't space the columns correctly! Is there a better way?

--

Julian Milano







All times are GMT +1. The time now is 12:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com