T
takilroy
Hi,
I am trying to implement this snippet of code from the .Net help
documentatiion so that I can modify the width of a textbox on one of my
aspx forms. However, for some reason visual studio thinks that
CreateGraphics is not a member (or method) of System.Web.UI.Control.
Can anyone help? Do I need to import something?
Private Sub AutoSizeControl(ByVal control As Control, ByVal
textPadding As Integer)
' Create a Graphics object for the Control.
Dim g As Graphics = control.CreateGraphics()
' Get the Size needed to accommodate the formatted Text.
Dim preferredSize As Size = g.MeasureString( _
control.Text, control.Font).ToSize()
' Pad the text and resize the control.
control.ClientSize = New Size( _
preferredSize.Width + textPadding * 2, _
preferredSize.Height + textPadding * 2)
' Clean up the Graphics object.
g.Dispose()
End Sub
Thanks,
Teresa
I am trying to implement this snippet of code from the .Net help
documentatiion so that I can modify the width of a textbox on one of my
aspx forms. However, for some reason visual studio thinks that
CreateGraphics is not a member (or method) of System.Web.UI.Control.
Can anyone help? Do I need to import something?
Private Sub AutoSizeControl(ByVal control As Control, ByVal
textPadding As Integer)
' Create a Graphics object for the Control.
Dim g As Graphics = control.CreateGraphics()
' Get the Size needed to accommodate the formatted Text.
Dim preferredSize As Size = g.MeasureString( _
control.Text, control.Font).ToSize()
' Pad the text and resize the control.
control.ClientSize = New Size( _
preferredSize.Width + textPadding * 2, _
preferredSize.Height + textPadding * 2)
' Clean up the Graphics object.
g.Dispose()
End Sub
Thanks,
Teresa