0

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?

Sougata
  • 319
  • 1
  • 10
  • See if this answers your question, https://stackoverflow.com/a/46038365/14525432 – AwiringCameron Jul 10 '21 at 13:30
  • @AwiringCameron not really. I do not understand C# but i think what the problem discussed over there is how to display all the available fonts as a dropdown list in a control. I have edited my question to make it more clear. – Sougata Jul 10 '21 at 14:07
  • The discussion shows how to load a list of the available windows fonts into a combobox, is this not what you are looking for? I can elaborate on it in vb.net if you want. – AwiringCameron Jul 10 '21 at 14:08
  • @AwiringCameron If you can do it in VB.Net that would be extremely helpful. I would be very interested to go through it. However I have edited my question...so pls do have a look at it. – Sougata Jul 10 '21 at 14:10
  • 1
    That color is a predefined enum with a fixed list of values. Fonts are different on every system, you might even be able to add a specific font to your application. So no enum-like intellisense – Hans Kesting Jul 10 '21 at 14:21

1 Answers1

2

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.

AwiringCameron
  • 620
  • 3
  • 18