I've been trying and trying to get the standard C# toolstrip control to format button text as multiline, and so far I've had to admit defeat.
What I'm trying to achieve is text under the picture, and the text wrapping a fixed icon size, rather than extending the开发者_如何学C icon size to accommodate the text, I'm not sure if I can explain it any easier - at the minute, the program looks like the following:
Icon Image
Icon Text - extending icon
whereas I actually want it to display as such:
Icon Image
Icon Text
Wrapped
Under Icon
I'm a bit stuck as to explain it any better than that, there's no multiline property on icons, and they don't accept the standard \n escape to force a newline.
I've got a horrid thought that I'm going to need to create a custom toolstripbutton class in order to do this, but I'm at a complete loss as to where to begin with that, so any help is graciously appreciated!
Thanks in advance for any assistance :)
You can programmatically set the Text property of the ToolStripButton like this:
toolStripButton1.Text = "Hello\nWorld!";
Run this in your form's constructor.
Of course you'd also set your ToolStripButton's ImageTextRelation
property to ImageAboveText
and its DisplayStyle
to ImageAndText
.
I used this code to display the text property in two lines;
toolStripButton1.Text = "Hello" + Environment.NewLine + "World!";
精彩评论