Click here to Skip to main content
15,886,832 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
were is the code that i did make but it don't work ?

VB
RichTextBox1.SelectionFont = New System.Drawing.Font(ComboBox1.Text, ComboBox2.Text, RichTextBox1.SelectionFont.Style)
Posted
Comments
LanFanNinja 3-Dec-11 18:16pm    
What exactly about this code is not working?
One thing I see right away is that you are trying to pass a string where a Single is required.

You need to Change from

New System.Drawing.Font(ComboBox1.Text, ComboBox2.Text,
RichTextBox1.SelectionFont.Style)

to something like this

New System.Drawing.Font(ComboBox1.Text, Single.Parse(ComboBox2.Text),
RichTextBox1.SelectionFont.Style)
Sergey Alexandrovich Kryukov 3-Dec-11 22:53pm    
The question is: what do you want to get? What should be different in new font?
--SA

1 solution

Exactly as LanFanNinja said in above comment you are passing String Value where you have to pass Single.I think you are using Vb.Net languge
The syntax to Set Font for RichTextBox is as follows :
VB
RichTextBox1.SelectionFont = New Font("Tahoma", 12, FontStyle.Bold)

You change your code and try this :
VB
RichTextBox1.SelectionFont = New System.Drawing.Font(ComboBox1.Text, CType(ComboBox2.Text, Single), RichTextBox1.SelectionFont.Style)
 
Share this answer
 
Comments
RaviRanjanKr 4-Dec-11 9:14am    
My 5+
Manoj K Bhoir 4-Dec-11 11:22am    
Thanks RaviRanjankr!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900