Results 1 to 7 of 7

Thread: quick question about creating buttons at runtime

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Question 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.

    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    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


    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

  4. #4
    Frenzied Member
    Join Date
    Aug 2005
    Posts
    1,042

    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:
    1. Me.Button1.Size = New System.Drawing.Size(78, 56)
    2. Me.Button1.TabIndex = 0
    3. Me.Button1.Text = "Select Image"
    If I reduce the width from 78 to 68 "Select Image" appears on two lines:
    VB Code:
    1. Me.Button1.Size = New System.Drawing.Size(68, 56)
    2. Me.Button1.TabIndex = 0
    3. Me.Button1.Text = "Select Image"
    I'm not sure if this will solve your problem or not.

    Good Luck

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    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!
    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

  6. #6
    Frenzied Member
    Join Date
    Aug 2005
    Posts
    1,042

    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.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Re: quick question about creating buttons at runtime

    Ok. Thanks.

    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width