本文的代码示例主要展示当终端用户按下Ctrl+Del 快捷键时,删除焦点行的操作。要处理按键事件,首先我们需要处理BaseView.KeyDown事件。然后通过调用ColumnView.DeleteRow 方法,删除焦点行。
C#
private void gridView1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == Keys.Delete && e.Modifiers == Keys.Control) { if (MessageBox.Show("Delete row?", "Confirmation", MessageBoxButtons.YesNo) != DialogResult.Yes) return; GridView view = sender as GridView; view.DeleteRow(view.FocusedRowHandle); } }
VB
Private Sub GridView1_KeyDown(ByVal sender As Object, _ ByVal e As System.Windows.Forms.KeyEventArgs) Handles GridView1.KeyDown If (e.KeyCode = Keys.Delete And e.Modifiers = Keys.Control) Then If (MessageBox.Show("Delete row?", "Confirmation", _ MessageBoxButtons.YesNo) <> DialogResult.Yes) Then Return Dim view As GridView = CType(sender, GridView) view.DeleteRow(view.FocusedRowHandle) End If End Sub
本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/382.html
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/382.html