Does anyone know how to change textbox properties at run time. I am trying to control alignment through a command button but the statement txtuserarea.alignment= 0 (for left) just gives me errors. any suggestions?
Matt
Printable View
Does anyone know how to change textbox properties at run time. I am trying to control alignment through a command button but the statement txtuserarea.alignment= 0 (for left) just gives me errors. any suggestions?
Matt
Hi Matt.
In order to be able to change the Alignment of a text box, its Multiline Property must be set to True.
Hope this helps.
Chris
Sure heres come code I tried to use from vb help file. text1.alignment = 0. The zero is soppose to be the setting for left justification. I have the feeling im using the wrong procedure for this.
After Martin's reply, I did some research and this is what I discovered.
The Alignment Property is read-only at run-time in VB5. However, in VB6 it can be changed at run-time.
If you do change it in VB6 while running your program and the Multiline Property is set to False, the Text box's alignment will not be effected by your code (e.g., it will remain Left-justified (the Default) despite the statement Text1.Alignment = 2).
All the best.
Chris
Thanks for the help
I obviously have VB6 and not VB5 (my apologies Chris), but I think this would work in VB5. Create a second textbox with the properties you want and at design time set it's Visible property to False. Then in a command button do the following:The above uses a TextBox control array. You could adapt it to use seperate TextBoxes if you want to.Code:Private Sub Command1_Click()
Const LEFT_ALIGN_TB = 0
Const CENTER_ALIGN_TB = 1
Text1(CENTER_ALIGN_TB).Text = Text1(LEFT_ALIGN_TB).Text
Text1(CENTER_ALIGN_TB).Top = Text1(LEFT_ALIGN_TB).Top
Text1(CENTER_ALIGN_TB).Left = Text1(LEFT_ALIGN_TB).Left
Text1(CENTER_ALIGN_TB).Width = Text1(LEFT_ALIGN_TB).Width
Text1(CENTER_ALIGN_TB).Height = Text1(LEFT_ALIGN_TB).Height
Text1(CENTER_ALIGN_TB).Visible = True
Text1(LEFT_ALIGN_TB).Visible = False
End Sub
------------------
Marty
Why is it called lipstick if you can still move your lips?
[This message has been edited by MartinLiss (edited 01-26-2000).]
I'm sorry, but Chris' statement is not true. You should be able to change the alignment of the text in the textbox at any time, with or without MultiLine set to True. Please post some of your code and perhaps we can find what's wrong.
------------------
Marty
Why is it called lipstick if you can still move your lips?