ADO.NET 2.0 - Get the value current record using the DataGridView

  • Thread starter Thread starter Phil Williams
  • Start date Start date
P

Phil Williams

Hello,
I have a Contacts DataGridView that is bound to the
TblContactsBindingSource.

The Grid contains a list of contacts including the contacts name (Column 2
or "ContactName")
I would like to get the value of the current "ContactName".

What is the easiest way to do this?


Thanks in Advance
Phil
 
Phil,

In this kind of questions is forever important in which event.

In fact is everywhere the currencymanager the most easiest class to handle
your question, however that needs that you know more from binding than
mostly is known by people using the designer.

Cor
 
Hi,

Phil Williams said:
Hello,
I have a Contacts DataGridView that is bound to the
TblContactsBindingSource.

The Grid contains a list of contacts including the contacts name (Column 2
or "ContactName")
I would like to get the value of the current "ContactName".

What is the easiest way to do this?

Dim contactName As String =
CStr(DirectCast(TblContactsBindingSource.Current,
DataRowView)("ContactName"))

or

Dim contactName As String = CStr(DataGridView.CurrentRow.Cells(1).Value)


HTH,
Greetings
 
Back
Top