Results 1 to 3 of 3

Thread: cells in a datagrid

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2004
    Location
    New York City
    Posts
    69

    cells in a datagrid

    Is there any way to get the cell position on a datagrid just by clicking on that particular cell?

    e.g. if i click on a cell in the datagrid just to get a message box returning the exact position of that cell. I just want to play around with some code to add an onclick event that would insert a combobox on that location since it looks like is the easiest way to do it.

    Thanks in advance for your replies.
    None for now

  2. #2
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: cells in a datagrid

    Hi
    VB Code:
    1. Private Sub DataGrid1_mouseup(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseUp
    2.  
    3.  
    4.         Try
    5.             If e.Button = MouseButtons.Left Then
    6.                 rightMouseDownPoint = Cursor.Position
    7.                 Dim pt As New Point(e.X, e.Y)
    8.                 Dim hti As System.Windows.Forms.DataGrid.HitTestInfo = DataGrid1.HitTest(pt)
    9.                 If hti.Type = Windows.Forms.DataGrid.HitTestType.Cell Then
    10.                     DataGrid1.CurrentCell = New DataGridCell(hti.Row, hti.Column)
    11.         Catch ex As Exception
    12.             MessageBox.Show(ex.Message)
    13.         End Try
    14.     End Sub

    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2004
    Location
    New York City
    Posts
    69

    Re: cells in a datagrid

    sorry to bother again with the same question but i am new to vb.net
    i asume that there are variable to declare and type. may you please give me some hints as of how to implement this event?
    thanks for your answer and i hope you can help me with this one.
    None for now

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width