Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2531
  • Last Modified:

VB.Net: How to set UNDERLINE in a textbox

Hello experts,
in my Vb.Net windows application I want to set
for a textbox the property underline.
In VB6 the statement is
   Me.Text1.FontUnderline = True
In Vb.Net the property
   Me.Textbox1.Font.Underline = ...
does not work, because it is here ReadOnly.

If anyone knows a solution how to set Underline,
please supply related code.

   Thank you very much for every help.

   HStrix
0
HStrix
Asked:
HStrix
2 Solutions
 
KaiNikulainenCommented:
Hi HStrix,
    You can set a new font to the textbox with desired properties:

    TextBox.Font = New Font(TextBox.Font, TextBox.Font.Style Or FontStyle.Underline)

Kaitsu
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You have to create a new Font based on the existing one but set the Underline style:

    Me.TextBox1.Font = New Font(TextBox1.Font, FontStyle.Underline)

~IM
0
 
HStrixAuthor Commented:
Thank you both,
your code is working.

  HStrix
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now