Hi,
I have a textbox into which text is written programatically.
As I have a structured text format, I want to change programatically to fixed size characters, like Curier .
I found out that TextBox (as well as RichTextBox) have numerous properties like FontFamily and FontName, but they are all read only.
As font is a standard TexBox property, there must be a way to change it programatically????????
Thaks,
Sam
Loading
theLizardPosted Oct 26, 2010, 4:35 PM
theLizardPosted Oct 26, 2010, 11:51 PM
I did not actually test it but did know that that was the way to do it...
SamPosted Oct 26, 2010, 11:01 PM
This one works fine (with slight casting to float change) as follows:
_displayWindow.Font = new Font("Courier New", (float)10.5, FontStyle.Regular);
SamPosted Oct 26, 2010, 3:33 PM
No, as I wrote in my previous reply and example, for most Font properties I get a read-only error.
The only editable properties are face (bold) and Italic.
The font type is read only.
What I did is to change the font in the fixed properties to Curier. It is not what I wanted, (I want to change it programatically) but due to time restriction it is reasonable.
If you have a solution to this, I'd be more than happy to accept and thank for.
Suthish NairPosted Oct 26, 2010, 2:22 PM
SamPosted Oct 26, 2010, 10:22 AM
Hello,
Thanks,
It looks simple and easy - but for all Font peoperties I get the message:
Error 1 Property or indexer 'System.Drawing.Font.Bold' cannot be assigned to -- it is read only
Is there a known 'read only' command that does it?
I built a simple form with a textbox as follows:
using System.Windows.Forms;
namespace TextboxTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void buildTextBox()
{
textBox1.Font.Bold = true; textBox1.Font.Name = "Thoma"; textBox1.Font.Size = 12;
}
}
}
Suthish NairPosted Oct 26, 2010, 9:49 AM