Reputation: 5729
I would like ton display a "ruler" on a textbox.
I'm thinking about displaying the u031D character in a textbox...
So i do this :
for (int nI = 0; nI <= TxtBox_ApercuFichier.Text.Length; nI++)
{
TxtBox_Regle.Text = TxtBox_Regle.Text.Trim() + "\u031D";
}
With this code, it only display on character. I i use a standard charactere, for a exemple, the letter "A", the concat is ok.
Do you know why ?
Thanks a lot :)
Regards,
Upvotes: 0
Views: 657
Reputation: 11514
\u031D
is not ASCII. That is a unicode code point. Apparently the characters between 0300 and 036F are combining characters, meaning they are only intended to modify other characters.
You can get them to show by providing characters on either side, but the result is probably still not what you are looking for:
textBox1.Text = textBox1.Text.Trim() + " " + "\u031d" + " ";
̝//yeilds : ̝ ̝ ̝ ̝ ̝
Update
I think this will get you started building a ruler on your form without trying to use text characters. Implement the paint event on your form:
private void Form1_Paint(object sender, PaintEventArgs e)
{
int counter = 0;
Point start = new Point(10, 50);
Point end = new Point(510, 50);
using (Pen thickpen = new Pen(Color.Black, 2f))
using (Pen thinpen = new Pen(Color.Black, 1f))
{
e.Graphics.DrawLine(thinpen, start, end);
for (int i = 0; i < 501; i += 5)
{
if (counter % 5 == 0)
{
e.Graphics.DrawLine(thickpen, start.X + i, start.Y, start.X + i, start.Y - 5);
}
else
{
e.Graphics.DrawLine(thinpen, start.X + i, start.Y, start.X + i, start.Y - 3);
}
counter++;
}
}
}
Upvotes: 1