[Gambas-user] How do I left justify text in a DataControl

Martin McGlensey mmcg29440 at ...3163...
Mon Apr 13 01:22:30 CEST 2015


Tobi,

 

Thanks for your response. I have a form with one datasource and twenty two
datacontrols within that datasource. They are used to display name, address,
city, state and other data that fits together logically on one form. Now if
I implement your solution I need to apply it to all of the datacontrols on
the form that display text. Can  I use a For each loop, with a test for type
= datacontrol, to set the text position to 0? If that will not work do I
have to set each datacontrol explicitly? Should I put the loop code in the
datasource_Change event?

 

Regards,

Marty

 

<A DataControl can take the form of one of TextBox, DateBox, ComboBox,
TextArea and ButtonBox, AFAICS. It's more difficult to find a general
solution, so I'll <restrict myself to the case that you are displaying an
Integer, Long, Float or String (with less than 256 characters) field which
are precisely the cases where the <DataControl uses a TextBox to display the
field.

< 

<Then you get that internal TextBox via DataControl.Control. You just take
this TextBox and go to cursor position zero:

< 

< Dim hTextBox As TextBox = myDataControl.Control

< 

< hTextBox.Pos = 0

< 

<This shows the left characters of the TextBox [ I have verified that it
works out like this, on my system ]. The other cases may be similar, except
DateBox which <has no Pos property.

< 

<If you have a DataSource -> DataBrowser -> DataControl in your project, the
appropriate place to put the above code would be the DataSource_Change event
<handler.

< 

<[ Also note that this is not about text alignment which you can control

<  separately with a TextBox but simply about what part of the long text

<  is displayed by the limited control. ]

 




More information about the User mailing list