Results 1 to 2 of 2

Thread: [2.0]Setting form width based on the Label box width?

  1. #1

    Thread Starter
    Addicted Member senthilkumartd's Avatar
    Join Date
    Feb 2005
    Posts
    206

    [2.0]Setting form width based on the Label box width?

    Hi,
    I tried to set the form width to the width of the label box. The following coding is not working. It's width is not changed.

    VB Code:
    1. private void lblMess_TextChanged(object sender, EventArgs e)
    2.         {
    3.             this.Width = lblMess.Width + 70;
    4.             this.Refresh();
    5.         }
    God has been pleased to place as a king or cobbler do the work sincerely

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

    Re: [2.0]Setting form width based on the Label box width?

    Have you set a break point on that method to confirm that it is being executed? Also, just because the Text of the label changes doesn't mean that the Width does. If its AutoSize property is True then it normally will, but it would still be more appropriate to handle its SizeChanged event.
    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

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