1

say i have a text box with readonly properties. It has text in the format [my string] i.e enclosed by square brackets.

I want if this textbox is focused and user press backbutton to delete this text, i know it wouldn't be possible as textbox is in readonly mode.

But still on pressing backbutton, Complete text will be delete not one char by one.

Rajeev Kumar
  • 4,901
  • 8
  • 48
  • 83

2 Answers2

1

Here is my solution..

I got it working my self

void txt_KeyPress(object sender, KeyPressEventArgs e)
    {
        if (e.KeyChar == '\b')
        {
            TextEdit textBox1 = sender as TextEdit;
            if (textBox1 != null)
            {
                textBox1.Text = "";
            }

        }
    }
Rajeev Kumar
  • 4,901
  • 8
  • 48
  • 83
0

Press Ctrl + A then press back button, it'll do the job,

TextBox tb = new TextBox();
tb.SelectAll();