Re: Entering text backwards



There may be some clever cultural trick available, but you could handle the
keypress event and do your own string construction, something along the
following. You would probably want to create your own subclassed textbox
control:

private void textBox1_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e)

{

TextBox txtBox = (TextBox) sender;

string text = txtBox.Text;

int selectionStart = txtBox.SelectionStart;


// Alphanumerics

if (33 <= e.KeyChar && e.KeyChar <= 122)

{

if (txtBox.SelectionStart == 0)

text = e.KeyChar + text;

else

{

text = text.Substring(0, selectionStart) + e.KeyChar +
text.Substring(selectionStart , text.Length - selectionStart);

}

e.Handled = true;

}


// Backspace -- treat as Delete

// unless some text is selected, in which case it behaves as normal

else if (e.KeyChar == 8 && txtBox.SelectionLength == 0 && selectionStart <
text.Length)

{

text = text.Remove(selectionStart, 1);

e.Handled = true;

}


// Delete -- doesn't get captured by KeyPress

txtBox.Text = text;

// return character entry point to original location

txtBox.SelectionStart = selectionStart;

}



"David" <David@xxxxxxxxxxxxx> wrote in message
news:16E43C83-AF2B-4A18-A2D8-AFAA9C58BF42@xxxxxxxxxxxxxxxx
> I want to enter text in a textbox, but have it appear right to left. I
want
> to keep the English cultural settings to do it. When I select RightToLeft
=
> yes, and TextAlign=left, the text ends up right aligned. The entry cursor
> appears to the left of previously entered text, but when I actually type
the
> text, it is entered on the right side.
>
> (I'm actually not trying to enter English text. I'm trying to enter
> Canaanite text. But since the operating system doesn't recognize
Canaanite
> as a cultural setting, I am keeping the English setting, and using a font
> that maps English characters to Canaanite glyphs. So what I'm really
trying
> to do is to have the text behave as if I were entering Hebrew, but since
the
> font maps to the ascii characters, I can't change to Hebrew settings,
because
> I want the keyboard mapping to remain unchanged.)


.



Relevant Pages

  • Re: Entering text backwards
    ... You would probably want to create your own subclassed textbox ... > text.Substring(selectionStart, text.Length - selectionStart); ... >> to keep the English cultural settings to do it. ... >> that maps English characters to Canaanite glyphs. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • RE: Hard Question - How to make a TextBox always write in English
    ... their source and then map these to english characters. ... therefore you will have to proxy the textbox ... Ronnie ... "Gidi" wrote: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to create a Multi Level List
    ... This is the textbox viewing the combined category levels: ... Language, English, English for business). ...
    (microsoft.public.access.tablesdbdesign)
  • Re: convert_lang_in_Textbox
    ... and i want to adjust textbox language as label caption lang. ... english mode when write into text box write english,when arabic form writting ...
    (microsoft.public.fox.programmer.exchange)
  • Entering text backwards
    ... to keep the English cultural settings to do it. ... But since the operating system doesn't recognize Canaanite ... to do is to have the text behave as if I were entering Hebrew, ...
    (microsoft.public.dotnet.framework.windowsforms)