How to use multiline button text?

I see that in vs 2005, writing in vb, that it can now apparently handle multiline button text. On the IDE, in the box that asks for my text, I can click on the drop down, and it opens a window where I can type in something like:

Main

Menu

(having pressed my Enter key after the word 'Main') and it shows exactly like I want it on the IDE. (Actually, I did not have a blank line between the two words--it's just doing that in this text editor). And, when I look at the generated code, it shows where it included the carriage return and line feed.

The problem is that when I deploy the program, or run the emulator, it does not show both lines; all I see is the word Main higher than normal in the button, but nothing else...similar to what vs2003 always did.

Any idea what is going on, and how to utilize this feature TIA



Answer this question

How to use multiline button text?

  • alex2308

    I appreciate the info. But will I have to get into this extra complexity in order to do multiline button text in vs 2005 (targeting CF 2.0)

    When I saw that drop-down text area on the button text line in vs 2005, and it allowed me to lay out multiple lines of text, and showed on the IDE, I assumed they had added that feature (which would be really nice). Is this apparent feature not what I think it is, or am I doing something wrong, or is it a bug in vs 2005, or what


  • dkorsunsky

    You will need to p/invoke to get the Button to handle multiline text on the device or emulator. If you use the p/invoke declarations at the link that I previously posted as well as place the following code in the Load event of the Form then you can update the Button style to properly display the multiline text. In addition, if you need to do this for more the one Button then you may choose to wrap this code in a method and just call the method once for each control, passing in the Button to update.

    Dim style As Integer
    style = GetWindowLong(Me.Button1.Handle, GWL_STYLE)
    SetWindowLong(Me.Button1.Handle, GWL_STYLE, style Or BS_MULTILINE)

    As for the Properties window allowing you to enter multiline text, my guess is that this was done simply to mirror the full desktop framework as it's just a matter of adding an attribute that points to a UITypeEditor named MultilineStringEditor. I don't believe that the intention was to support multiline text.



  • NewtoC

    Try changing the button style to be multiline, as shown at the link below, and see if that produces the result that you want. Keep in mind that if you're targeting CF 2.0 then you can get the hWnd of the control from the Handle property instead of the p/invoke.

    http://groups.google.com/group/microsoft.public.dotnet.framework.compactframework/msg/fbbcdb86857e8d3d hl=en



  • How to use multiline button text?