BASit Bulbulia
BASit Bulbulia

Reputation: 229

In one line I need to change the font type and also underline the font

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)

Upvotes: 0

Views: 132

Answers (1)

djv
djv

Reputation: 15774

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)

Upvotes: 1

Related Questions