Hi, i want to ask u something guys. i have one textbox. While writing in, after pressing Space, i want to intstead of white space, write this "|" . This is my code

void TextBox1KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
    {
    if (e.KeyChar == (char)Keys.Space)
         {
            textBox1.AppendText("|");

        }
      }

Problem is it dont write only "|" but "| " . After that char it put whitespace and cursor moves after that white space. I try to use method

textBox1.Text = textBox1.Text.Substring(0, (textBox1.TextLength - 1)); 

but it dont work because it delete my "|" no that whitespace, since whitespace is not char....

Thanks for any help

Edited 1 Year Ago by JOLO14

In your KeyPressEventArgs object is a Handled property. Set that guy before returning from the event handler to disable subsequent control logic on the event.

sorry but i dont understand, i use google translate to translate your answer because english is not my native language. And also my c# skills are not so high..If u could answer in basic or "lower" english..only words from your answer i undestand were: In your,that guy (but i dont think it mean that "man")

Edited 1 Year Ago by JOLO14

This question has already been answered. Start a new discussion instead.