Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. captur datagrid double click and key press

captur datagrid double click and key press

Scheduled Pinned Locked Moved Visual Basic
help
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    samithaslk
    wrote on last edited by
    #1

    I have tried out various code on capturing keypress and doubleclick events on the datagrid. But the problem is when you add the keypress support, the doubleclick won't fire out. here is the code for trapping double click Dim grdColStyle1As New DataGridKeyTrapTextBoxColumn grdColStyle1.MappingName = "Acc_Curr_Balance" grdColStyle1.HeaderText = "Account Balance" grdColStyle1.Width = 225 AddHandler grdColStyle1.TextBox.MouseDown, New MouseEventHandler(AddressOf TextBoxMouseDownHandler) AddHandler grdColStyle1.TextBox.DoubleClick, New EventHandler(AddressOf TextBoxDoubleClickHandler) Private Sub TextBoxMouseDownHandler(ByVal sender As Object, ByVal e As MouseEventArgs) If (DateTime.Now < gridMouseDownTime.AddMilliseconds(SystemInformation.DoubleClickTime)) Then btnOk_Click(sender, e) End If End Sub Private Sub TextBoxDoubleClickHandler(ByVal sender As Object, ByVal e As EventArgs) Try btnOk_Click(sender, e) Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub ' trap the key press Public Class DataGridKeyTrapTextBoxColumn Inherits DataGridTextBoxColumn Private _keyTrapTextBox As KeyTrapTextBox = Nothing Private _source As System.Windows.Forms.CurrencyManager = Nothing Private _rowNum As Integer Private _isEditing As Boolean = False Public Shared _RowCount As Integer = 0 Private mTxt1 As String Private mTxt2 As String Private mTxt3 As String Private mClicked As Boolean = False Public Sub New() _keyTrapTextBox = New KeyTrapTextBox _keyTrapTextBox.BorderStyle = BorderStyle.None AddHandler _keyTrapTextBox.Leave, AddressOf LeaveKeyTrapTextBox AddHandler _keyTrapTextBox.KeyPress, AddressOf TextBoxEditStarted End Sub 'New Private Sub TextBoxEditStarted(ByVal sender As Object, ByVal e As KeyPressEventArgs) _isEditing = True 'dim cm as CurrencyManager = 'If e.KeyChar = Chr(13) Then ' MsgBox(CType(sender, TextBox).Text) 'End If MyBase.ColumnStartedEditing(CType(sender, Control)) End Sub 'TextBoxEditStarted Private Sub LeaveKeyTrapTextBox(ByVal sender As Object, ByVal e As EventArgs) If _isEditing Then SetColumnValueAtRow(_source, _rowNum, _keyTrapTextBox.Text) _isEditing = False Invalidate() End If _keyTrapTextBox.Hide() End Sub 'LeaveKeyTrapTextBox Protected Overloads Overrides Sub Edit(ByVal [source] As System.Wind

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups