Home > front end >  In one line I need to change the font type and also underline the font
In one line I need to change the font type and also underline the font

Time:10-08

This is the code I tried but does not work . .

Dim lab As New Label
lab.Font = New System.Drawing.Font("Courier New", 8.25!, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, 0)

CodePudding user response:

Well, it does work. Did you add it to a form? Use Form.Controls.Add(Control)

enter image description here

You said "In one line", so...

Me.Controls.Add(New Label With {.Font = New System.Drawing.Font("Courier New", 8.25!, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, 0), .Location = New Point(10, 10), .Text = "abcDEF"})

but here it is a bit more readable

Dim lab As New Label()
lab.Font = New System.Drawing.Font("Courier New", 8.25!, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, 0)
lab.Location = New Point(10, 10)
lab.Text = "abcDEF"
Me.Controls.Add(lab)
  • Related