-
April 2nd, 2010, 10:42 PM
#1
Add new line to the text in a button
Hi folks,
The text I have in a button is too long and I wish to have it in 2 lines. How can I get the text in a button to the next line. Can anyone please help me with this ? I am using VS2008 and .NET 3.5.
Any help is appreciated. Thank you
-
April 3rd, 2010, 01:39 AM
#2
Re: Add new line to the text in a button
Code:
private void button1_Click(object sender, EventArgs e)
{
button1.Text = "line1\nline2";
}
Please rate my post if it was helpful for you. Java, C#, C++, PHP, ASP.NET
SQL Server, MySQL
DirectX
MATH Touraj Ebrahimi
[toraj_e] [at] [yahoo] [dot] [com]
-
April 3rd, 2010, 10:47 PM
#3
Re: Add new line to the text in a button
Hi Toraj,
I already tried that but only the first line gets printed. I do not know the reason for that. I also tried drawString method but the button covers the text. I do not know how to print the text over the button.
Thank you
-
April 4th, 2010, 12:57 AM
#4
Re: Add new line to the text in a button
have you tried \n and enlarged the Y size of it ?
-
April 4th, 2010, 12:18 PM
#5
Re: Add new line to the text in a button
Yep, I increased the Y size of the button but nothing changed. I can see just the first line.
-
April 4th, 2010, 01:21 PM
#6
Re: Add new line to the text in a button
Did you try adding the height of the button font?
Code:
button1.Height += button1.Font.Height;
-
April 4th, 2010, 01:29 PM
#7
Re: Add new line to the text in a button
Ok, i made a simple test on my VS2008...
When i made the button and enlarged it's vertical size and then typed what i wanted it did broke to new lines when it reached the end.
but if you create a new button and try to alter it's text it won't work.
So what i did to make it fit was:
Code:
button1.Height = 70;
button1.Text = "Trying to make the text fits into the button.";
since with 70px i was sure all that text would fit in.
someuser77 method also works but if u have a big text it won't show up everything at once...
-
April 4th, 2010, 02:38 PM
#8
Re: Add new line to the text in a button
What about setting the button AutoSize property to true? Do you need to limit the button width?
-
April 5th, 2010, 12:35 AM
#9
Re: Add new line to the text in a button
Hi someuser77, prixone
I tried both the method you mentioned and nothing worked. I did set the size of the button and also the button size + font size but got the same result. Please, let me know if there is any fix. Actually I am developing an application for smart phone and may be that's the reason I do not find autosize property for button.
Thank you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|