Get header name from data grid

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • neeraj

    Get header name from data grid

    Hi, all

    Could any one suggest me how to get the column name or
    column index of the datagrid , when user click on any column header of
    the grid in vb.net (windows) application ..

  • jvb

    #2
    Re: Get header name from data grid

    Try trapping the mousedown event and use the HitTestInfo class to find
    what part of the datagrid the user clicked.

    On Jan 25, 11:21 am, "neeraj" <neeraj....@gma il.comwrote:
    Hi, all
    >
    Could any one suggest me how to get the column name or
    column index of the datagrid , when user click on any column header of
    the grid in vb.net (windows) application ..

    Comment

    • Iouri

      #3
      Re: Get header name from data grid

      'get index and value
      Private Sub dgv_CellClick(B yVal sender As Object, ByVal e As
      System.Windows. Forms.DataGridV iewCellEventArg s) Handles dgv.CellClick
      Dim iRow As Integer = dgv.CurrentRow. Index
      Dim iCol As Integer = dgv.CurrentCell .ColumnIndex
      dgv.CurrentCell = dgv(iCol, iRow)
      MsgBox(dgv.Curr entCell.Value)

      End Sub

      'get header text
      Private Sub Button9_Click(B yVal sender As Object, _
      ByVal args As EventArgs) Handles Button9.Click

      For Each column As DataGridViewCol umn _
      In dataGridView.Co lumns

      Next
      End Sub


      "neeraj" <neeraj.nav@gma il.comwrote in message
      news:1169742061 .559937.164630@ m58g2000cwm.goo glegroups.com.. .
      Hi, all
      >
      Could any one suggest me how to get the column name or
      column index of the datagrid , when user click on any column header of
      the grid in vb.net (windows) application ..
      >

      Comment

      Working...