Results 1 to 6 of 6

Thread: Need to increase width of control automatically

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Thumbs up Need to increase width of control automatically

    Hi,

    I retrieve name from database in my "Name" table(tblname). lots of large and small name is stored. eg: alex mandra george, stephen, Tara jessy nock.

    I retrieve data from database and store in the label control. I fixed the width for this label. Once is very large name stored it may be extended from my label width. The control will change automatically and need to show full name. If i put width:auto Is it possible that it is changed automatically??

    hope urs reply??
    Failing to plan is Planning to fail

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Need to increase width of control automatically

    Hey,

    Can you provide a screen shot of what you are referring to?

    I am struggling trying to picture what you are doing!?!?

    Gary

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Thumbs up Re: Need to increase width of control automatically

    Hi gep,

    A label inside i get the value from db. How it would be? Gep123 is showing in label.ok. while i retrieve from db and assign to label. Its small name. My label width is fixed. (eg;30px) Suppose the name is large, it mean its showing in label but we cant see full name for this width. eg: Alexandar lieopard is name. The label is not enough for this name in design. So what we do? we just click on the label and move cursor and read full name. I dont want to read using mouse cursor. Whatever name will come (large or small) the label width is adjustable.
    Is it possible?? This is my question. sorry i couldnt place image here.

    Hope yours reply.

    Thanks
    Failing to plan is Planning to fail

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Need to increase width of control automatically

    Hey,

    So, what happens when you set the size of the label to Auto? Does that not work for you?

    The other way would be to use MeasureString:

    http://msdn.microsoft.com/en-us/libr...urestring.aspx

    On the text that is returned from the Database, and then set the size of the Label control.

    Gary

  5. #5
    Junior Member
    Join Date
    Mar 2005
    Posts
    30

    Re: Need to increase width of control automatically

    Hey, I know I've come across this in repeater controls...so, not sure if it's the same scenario in a label, but I think so...anyway, are setting the width by setting the "style" attribute of the control? Typically, I found that if you use the "style=width:somewidth" then that sticks, but if you use the Width attribute directly on the control, it will resize to fit the text in the control...

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Need to increase width of control automatically

    Don't set a width on the label at all then. The label will automatically expand (it's a <span>) to accommodate the contents (the long name).

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