quick question about creating buttons at runtime
Hi guys,
I am using .net compact framework 2.0.
This may be an easy question to answer but i cant seem to solve it myself. I am creating a button at run-time and i need the text on the button to appear on two lines. I want the button to say
Select
Image
When i say Button1.Text = "Select Image" it puts it on 1 line (and my button is not wide enough to display it on one line), and when i try
Button1.Text = "Select" & controlchars.newline & "Image", it never displays the image part of the text no matter how big i make the height of the button.
Can anybody tell me how to get the text on the button like i want it displayed above? And why none of my earlier attempts have worked.
Thanks in advance for any help.
:afrog:
Re: quick question about creating buttons at runtime
This doesn't really solve your problem but I just tried setting the text to a multiline string at design time and that didn't work either. It doesn't look like a CF Button actually renders a line break as a line break, but rather tries to render the characters themselves and fails because they have no visual representation.
Re: quick question about creating buttons at runtime
Ok thanks for the quick reply.
I guess i'll just have to shorten the text.
Thanks again
:thumb:
:wave:
Re: quick question about creating buttons at runtime
Kimmy4:
I think it is the width you need to adjust and not the height.
And, it will also depend on the size of the font you are using.
If I use the following code I get "Select Image" on one line:
VB Code:
Me.Button1.Size = New System.Drawing.Size(78, 56)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Select Image"
If I reduce the width from 78 to 68 "Select Image" appears on two lines:
VB Code:
Me.Button1.Size = New System.Drawing.Size(68, 56)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Select Image"
I'm not sure if this will solve your problem or not.
Good Luck
Re: quick question about creating buttons at runtime
Is that in the compact framework? When i adjust the width it jus cuts off part of the text from the beginning and end, keeping it all on one line!
Re: quick question about creating buttons at runtime
Kimmy4:
No. Sorry, its VS2005.
And, it doesn't work the same in net compact framework 2.0.
Re: quick question about creating buttons at runtime