2024年终活动

DevExpress控件使用交流,DevExpress中国社区Dev联系电话 联系电话:023-68661681

DevExpress XtraGrid网格控件示例二:利用快捷键删除行

来源:本站原创   发布时间:2012-10-16   浏览:3882次

本文的代码示例主要展示当终端用户按下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
扫码咨询
电话咨询
023-68661681
返回
顶部