vbAccelerator sGrid control- spacing columns.

  • Thread starter Thread starter Julian Milano
  • Start date Start date
J

Julian Milano

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?
 
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
 
Back
Top