Hello everyone, I have run into an error I have never seen before and I am unsure on how to resolve this.
richtextbox.SelectionFont.Size = 5f; //This causes the error, just trying to define a font size.
Property or indexer 'System.Drawing.Font.Size' cannot be assigned to -- it is read only
Anyone have any idea on how to fix this? What is the point of having access to a value and then being restricted from changing it?
Thank you,
Ryan
Ryan TurneyPosted Feb 13, 2008, 6:18 PM
Scott LyslePosted Feb 13, 2008, 4:01 AM
You have to replace the font; you set the font size and leave all else the same you could do something like this:
This will change the font size to 10:
System.Drawing.Font currentFont = richTextBox1.SelectionFont; richTextBox1.SelectionFont = new Font(currentFont.FontFamily, 10);This will change the font size to 14:
System.Drawing.Font currentFont = richTextBox1.SelectionFont; richTextBox1.SelectionFont = new Font(currentFont.FontFamily, 14);