Common/GridBuilder: Add WithClipboardHandler
This commit is contained in:
parent
e6b9bc30df
commit
9578a36b41
@ -1,4 +1,5 @@
|
||||
Imports System.Drawing
|
||||
Imports System.Windows.Forms
|
||||
Imports DevExpress.XtraGrid.Views.Grid
|
||||
Imports DevExpress.XtraTreeList
|
||||
|
||||
@ -80,4 +81,28 @@ Public Class GridBuilder
|
||||
|
||||
Return Me
|
||||
End Function
|
||||
|
||||
Public Function WithClipboardHandler() As GridBuilder
|
||||
For Each oGridView In Views
|
||||
WithClipboardHandler(oGridView)
|
||||
Next
|
||||
|
||||
Return Me
|
||||
End Function
|
||||
|
||||
Public Function WithClipboardHandler(View As GridView) As GridBuilder
|
||||
AddHandler View.KeyDown, AddressOf GridView_ClipboardHandler
|
||||
|
||||
Return Me
|
||||
End Function
|
||||
|
||||
Private Sub GridView_ClipboardHandler(sender As Object, e As KeyEventArgs)
|
||||
Dim view As GridView = CType(sender, GridView)
|
||||
If e.Control AndAlso e.KeyCode = Keys.C Then
|
||||
If view.GetRowCellValue(view.FocusedRowHandle, view.FocusedColumn) IsNot Nothing AndAlso view.GetRowCellValue(view.FocusedRowHandle, view.FocusedColumn).ToString() <> [String].Empty Then
|
||||
Clipboard.SetText(view.GetRowCellValue(view.FocusedRowHandle, view.FocusedColumn).ToString())
|
||||
End If
|
||||
e.Handled = True
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user