Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Dynamically changing the width

Reply
Thread Tools

Dynamically changing the width

 
 
Mike Towle
Guest
Posts: n/a
 
      04-14-2004
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?
 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      04-14-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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?


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically Resize Gridview Width Property (NOT Column Width) Hartman_Ralph@Hotmail.com ASP .Net 0 06-02-2009 03:59 PM
Changing width of a datagrid column dynamically Veeves Javascript 1 04-17-2006 01:39 PM
Textbox width scaling to width of data not width of page? AndrewF ASP .Net 1 10-10-2005 04:38 PM
JComboBox width, dropdown list width Xu Java 11 07-15-2005 11:54 PM
Re: resized image in table extends table width to original image width Sean Jorden HTML 1 08-19-2003 08:59 AM



Advertisments