Is it possible to create a text box that receives data from right to left? [Answered]
Imagine if you had to solve a problem like
57281
* 38268
Don't use a calculator, when you start writing down the answer do you start from the right and go left, or start from the left and go right?
Whenever you enter information into a textbox for winforms the text always goes left to right, is there a way to change this?
37 Replies
it doesn't make any sense to change it
if you want to calculate character by character, you can do it starting from the last character
would it be fair to assume that it is not possible? regardless as to rather it makes sense?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
ty, I did try
txtBox_Calculation.TextAlign = HorizontalAlignment.Right;
but that didn't seem to work for some reason.
neither one seems to work
TextAlign is only for the placement of the text to be centered or anchored to the dide
RightToLeft to invert the characters
I'd like to invert the characters I suppose
very close to what I needed, but not quite
I guess the best way for me to put what I'm trying to explain is imagine if you were writing in Arabic or Hebrew, you write right to left. I don't think it's possible with studio though.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
That crashed my program lol
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
how do you put code in here like that that looks clean
private void txtBox_Calculation_TextChanged(object sender, EventArgs e)
{
if (txtBox_Calculation.Text.Length <= 1) return;
var allWithoutLastChar = txtBox_Calculation.Text[..^1];
var lastChar = txtBox_Calculation.Text[txtBox_Calculation.Text.Length - 1];
txtBox_Calculation.Text = lastChar + allWithoutLastChar;
}
mine is different, what is the KeyUp?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
ty
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
That screenshot I took the function txtBox_Calculation_KeyUP doesn't do anything
Like I'm typing into the box after building it and same problem except I'm not crashing
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I'm not sure what you mean by subscribed
did I write characters into the text box that is associated to keyups?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
So it is an event to the blank line of code?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
will do thank you
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I should've asked you what that line means
var allWithoutLastChar = txtBox_Calculation.Text[..^1];
I've never seen an array with ..^1 inside of it
Apparently there is a right to left setting for text boxes but it only works with rtl languages, not numbers.
I ended up doing this, but am getting a bad error
Been trying to figure this out for the past 2 hours, at what point does coding become easier?
How is it out of bounds when the index is 0?
Every time I have a lead it drops me back to the start
The only other thing I can think of is when I enter a value into the box have the program somehow activate my left arrow key button. Which also is not on the internet anywhere
https://github.com/RobGreen490/Ch5-AdditionTutor.git
The time I'm looking for is dextrosinistral
How can I make it where my textbox accepts any and all input as dextrosinistral
There is an option in the properties of the text box called events
Where you can find a keyup event to set
Which fixes this problem
Now how do i make this post solved
/solved
solved
@Hisme I ended up inserting this code into my txtBox
txtBox_Calculation.SelectionStart = 0;
This code somehow always kept my cursor to the left when entering anything, which was exactly what I needed.
I figured out what you meant by that other code, but it was kind of faulty. It would leave me off at the 2nd selectionStart point
✅ This post has been marked as answered!