//private void keyHook_KeyDown(object sender, KeyEventArgs e) private void queryCB_KeyDown(object sender, KeyEventArgs e) {
if (e.Control == true && e.KeyCode == Keys.C) { Clipboard.SetText(queryCB.SelectedText); e.Handled = false; e.SuppressKeyPress = true; return; } else if (e.Control == true && e.KeyCode == Keys.V) { queryCB.Text = Clipboard.GetText(); e.Handled = false; e.SuppressKeyPress = true; return; }
switch (e.KeyCode) { case Keys.RShiftKey: enabledBU_Click(this, new EventArgs()); break; case Keys.Enter: e.Handled = false; e.SuppressKeyPress = true; if(queryCB.Text.Trim().Length >0) beginQueryBU_ButtonClick(this, new EventArgs()); break; case Keys.BrowserBack: e.Handled = false; e.SuppressKeyPress = true; break; case Keys.Back: e.Handled = false; e.SuppressKeyPress = true; if (queryCB.Text.Length > 0) { try { int sLength = queryCB.SelectionLength == 0 ? 1 : queryCB.SelectionLength; int position = queryCB.SelectionLength == 0 ? queryCB.SelectionStart - 1 : queryCB.Text.IndexOf(queryCB.SelectedText); queryCB.Text = queryCB.Text.Remove(position, sLength); queryCB.SelectionStart = position > queryCB.Text.Length ? queryCB.Text.Length : position; queryCB.SelectionLength = 0; queryCB.Select(); } catch { } } break; case Keys.Delete: e.Handled = false; e.SuppressKeyPress = true; if (queryCB.Text.Length > 0 && queryCB.SelectionStart < slength =" queryCB.SelectionLength" position =" queryCB.SelectionStart;" text =" queryCB.Text.Remove(position," selectionstart =" position"> queryCB.Text.Length ? queryCB.Text.Length : position; queryCB.SelectionLength = 0; queryCB.Select(); } break; case Keys.Left: e.Handled = false; e.SuppressKeyPress = true; queryCB.SelectionLength = 0; if (queryCB.SelectionStart > 0) queryCB.SelectionStart = queryCB.SelectionStart - 1; break; case Keys.Right: e.Handled = false; e.SuppressKeyPress = true; queryCB.SelectionLength = 0; if (queryCB.SelectionStart < queryCB.Text.Length) queryCB.SelectionStart = queryCB.SelectionStart + 1; break; case Keys.Down: e.Handled = false; e.SuppressKeyPress = true; break; default: e.Handled = false; e.SuppressKeyPress = true; break; } }
沒有留言:
張貼留言