How to get value from an row in DataView?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dejan Pajic
    New Member
    • Nov 2010
    • 1

    #1

    How to get value from an row in DataView?

    Hello to everyone!

    I am new to VB.NET 2010 Express and ADO.NET, trying to convert an application (VB6, ADO 2.5).

    There is an DataView (dv) with 2 fields fld1 (ID) and fld2. There is also an DataGridView (dgv), with just one, predefined as read only, column fld2. Field fld1 (ID) is not visible. DataGridView (dgv) is binded to DataView, so:

    ...
    dgv.AutoGenerat eColumns = False
    dgv.DataSource = dv
    ...

    While focus is in TextBox (txt) user can hit Down/Up arrow keys and scroll up and down through dgv (and dv), so:

    Private Sub txt_KeyDown(ByV al sender As Object, ByVal e As System.Windows. Forms.KeyEventA rgs) Handles txt.KeyDown
    ...
    BindingContext( dv).Position +/-= 1
    ...
    End Sub

    After any of the rows in dgv is marked, user presses Enter/Return (focus is stil at txe TextBox). Everything, so far, is working just fine.

    My question is how to get the value of the field fld1 (ID) for the current row (selected in dgv).

    This is, I belive, simple thing, but took me few hours looking for solution similar to one I did with ADO 2.5 Recordset.

    Thanks in advance,
    Dejan
Working...