Reputation: 187
I'm making a calculator in c#. I know the logic required to make a calculator. But the problem I'm facing is with the UI, I want to make the text in my TextBox Right and Bottom, while there is TextAlign property which makes the text in the TextBox align to right, I'm having trouble making it align to the bottom?.I really tried finding an answer.
but I want something like this
Also how to move the text in the textbox slightly upper when I press any operator?
Upvotes: 1
Views: 6044
Reputation: 21
Think this is possible with a RichTextBox
but it would be a long work around. I would suggest using a Label
. To align the text to the bottom right in a label you can use:
label.TextAlign = ContentAlignment.BottomRight;
To change the look of the Label
you can use:
label.BackColor = Color.White;
label.BorderStyle = BorderStyle.FixedSingle;
To change the label from looking like a single line:
label.AutoSize = false;
label.Size = new Size(100,100)
Upvotes: 0
Reputation: 1079
Assuming the fact that you only use the TextBox
for displaying the user input, a Label
will allow for better use of what you want.
The Label
supports a wider use of TextAlign
so you could use
Label1.TextAlign = ContentAlignment.BottomRight;
If you want to create multiple lines inside the label, you can use Environment.NewLine
to achieve that for example. But a StringBuilder
and using AppendLine
will probably work too.
If you really need to use a TextBox
to achieve your needs, your best option would probably be to write a custom TextBox
which supports your wanted text align.
Upvotes: 1