Sougata
Sougata

Reputation: 337

Is there a way to get a dropdown of Fonts?

b is an instance of the button class. Following are two ways to set the Font of the button b. But in both cases, I have typed out the word ‘Calibri’. Is there a way to pull ‘Calibri’ through some property or method so that we don’t have to type it? Ideally I would like to get a dropdown list from where I can choose a font (something similar to choosing colours). Is that possible?

b.Font = New Font("Calibri", 20)

OR

Dim fontF As New FontFamily("Calibri")
b.Font = New Font(fontF, 20)

Also, if the above is not possible, is there a way to find out the complete list of fonts available to be used in the WinForms I am trying to create? PLease note that I am looking for something as following: b.FlatAppearance.BorderColor = Color.Red. Here 'Red' comes as a dropdown after I type Color.Red. Is a similar thing possible while setting fonts for a button?

Upvotes: 0

Views: 274

Answers (1)

AwiringCameron
AwiringCameron

Reputation: 640

I understand you would like intellisense to provide a list of font names when typing. Unfortunately this isn't available directly. You can however, open the designer for the form, select a button and open the font editor:

enter image description here

Then select the font you would like, copy the name, cancel the dialog, and paste the name into your code; or set the font directly through the designer properties with this dialog. Whichever fits your scenario.

Upvotes: 2

Related Questions