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
Printable View
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
Code:
private void button1_Click(object sender, EventArgs e)
{
button1.Text = "line1\nline2";
}
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
have you tried \n and enlarged the Y size of it ?
Yep, I increased the Y size of the button but nothing changed. I can see just the first line.
Did you try adding the height of the button font?
Code:button1.Height += button1.Font.Height;
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:
since with 70px i was sure all that text would fit in.Code:button1.Height = 70;
button1.Text = "Trying to make the text fits into the button.";
someuser77 method also works but if u have a big text it won't show up everything at once...
What about setting the button AutoSize property to true? Do you need to limit the button width?
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