Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make negative signs appear on the left of numbers in a right to left box in C#?

I'm developing a calculator in C# and I ran into a stumbling block. As usual calculators do, I have my text box set to RightToLeft. However, when I convert the number to a negative number using my + - button, the negative sign always goes to the RIGHT of the number, not the left. How do I make it appear on the left side using a right to left box?

My negative converter:

decimal neg;
neg = number * 2;
number = number - neg;
richTextBox1.Text = Convert.ToString(number);
like image 418
user3587709 Avatar asked Dec 19 '22 15:12

user3587709


1 Answers

As usual calculators do, I have my text box set to RightToLeft.

No, that’s not what usual calculators do. Set TextAlign instead. (And use a regular TextBox, not a RichTextBox. RichTextBoxes are hard to format, but you can select the entire thing and use SelectionAlignment if you really need to.)

like image 125
Ry- Avatar answered Apr 06 '23 01:04

Ry-