Reputation: 125
I have a richTextBox with some text (for example: Hello world). My aim is to make 2 combo boxes which i can choose a font and font size. The richtTextBox should change the font for the whole text.
For example: that is from Word.
It will be nice when someone can tell me how can i begin that or what must i search in google. I search now a whole day and find only posts with the font dialog.
I use Visual Studio with WindowsFormsApplication
Question:
How can I make the combo boxes in C# like on the picture?
With friendly wishes sniffi
Upvotes: 0
Views: 97
Reputation: 899
Yo can use InstalledFontCollection
.
On the load:
InstalledFontCollection IFC = New InstalledFontCollection();
ComboBox1.DisplayMember = "Name";
ComboBox1.DataSource = IFC.Families;
You will have the combo with all the fonts, and displaying its name.
Upvotes: 2
Reputation:
It is not too hard. You need to find all fonts installed on the current machine, populate the combo box with them, and when the user selects an item from the combo box you change your font depending on the selection.
To find installed fonts: https://stackoverflow.com/a/8657854/4795214
Upvotes: 1
Reputation: 6538
If you are using WPF you can do it with one line of code :
<ComboBox ItemsSource="{Binding Source={x:Static Fonts.SystemFontFamilies}}"/>
This line will generate a combobow with all fonts present in SystemFontFamilies.
Upvotes: 1