Dynamically changing the width

Discussion in 'ASP .Net Web Controls' started by Mike Towle, Apr 14, 2004.

  1. Mike Towle

    Mike Towle Guest

    I would like to autosize the width of a textbox control based on the value of the control. Is there a function that will determine what the width should be for a control based on the text value of the control or a string that I pass it?
     
    Mike Towle, Apr 14, 2004
    #1
    1. Advertising

  2. Hi Mike,

    Changing the width is the easy part. The hard part is finding the correct
    value that represents the pixel width of the font being used. Not sure out
    to do that.

    Dim decPixelsPerChararacter As Decimal = 6.5
    Dim strText As String = "This is my long string which" & _
    " I need to measure."
    Dim intLength As Integer
    intLength = Len(strText) * decPixelsPerChararacter
    TextBox2.Width = New WebControls.Unit(intLength)
    TextBox2.Text = strText


    "Mike Towle" <> wrote in message
    news:...
    >I would like to autosize the width of a textbox control based on the value
    >of the control. Is there a function that will determine what the width
    >should be for a control based on the text value of the control or a string
    >that I pass it?
     
    Ken Cox [Microsoft MVP], Apr 15, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AndrewF
    Replies:
    1
    Views:
    811
    Bruce Barker
    Oct 10, 2005
  2. Xu
    Replies:
    11
    Views:
    8,605
    Andrew Thompson
    Jul 16, 2005
  3. Sean Jorden
    Replies:
    1
    Views:
    609
    laurie
    Aug 19, 2003
  4. Replies:
    0
    Views:
    945
  5. Veeves
    Replies:
    1
    Views:
    91
Loading...

Share This Page