Why are some textboxes not accepting Control + A shortcut to select all by default

后端 未结 5 1205
野趣味
野趣味 2020-12-08 10:05

I have found a few textboxes here and there in my program that accepts Control+A shortcut to select the entire text \"by default\" with \"no coding\".

I don\'t know

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-08 10:26

    Indeed CTRL + A will not work unless you add something like this:

      private void textBox1_KeyDown(object sender, KeyEventArgs e)
      {
          if (e.Control && (e.KeyCode == Keys.A))
          {
              if (sender != null)
                   ((TextBox)sender).SelectAll();
              e.Handled = true;
          }
      }
    

提交回复
热议问题