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

Tobias Boege taboege at ...626...
Mon Apr 13 09:09:04 CEST 2015


On Sun, 12 Apr 2015, Martin McGlensey wrote:
> -----Original Message-----
> Message: 1
> Date: Sun, 12 Apr 2015 16:20:59 +0200
> From: Tobias Boege <taboege at ...626...>
> Subject: Re: [Gambas-user] How do I left justify text in a DataControl
> To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
> Message-ID: <20150412142059.GI3785 at ...2774...>
> Content-Type: text/plain; charset=us-ascii
> 
> On Sun, 12 Apr 2015, Martin McGlensey wrote:
> > How do I force a DataControl to display text, that is longer than the 
> > control,  as left justified. That is if the control is sized to accept 
> > ten characters, on the form,  and the text is twenty characters I want 
> > to see the first ten. Now I see the last ten. Want to see the first 
> > ten and be able to arrow over to see the next ten. Is there an align 
> > property to address this?
> > 
> > All solutions are welcome.
> > 
> 
> 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. ]
> 
> Regards,
> Tobi
> 
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
> 
> Tobi,
> 
> Dim hTextbox as TextBox = DataControl.Control does not appear to work. Error
> - Expecting number etc. Dim hTextArea as TextArea = DataControl.Controls
> does work without error. Is that expected with a datacontrol or have I  made
> an error?
> 

Likely but since I don't have access to your computer, I can't check your
code. (Should it work like this?)

Have you replaced the "DataControl" with your DataControl's name? Do you
really use DataControl.Control*s* the second time? Are you sure your
database field is a CHAR(N) where 0 < N < 256? If not, the DataControl
becomes a TextArea instead of a TextBox.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list