Home All Groups Group Topic Archive Search About

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

Author
7 Feb 2006 3:57 AM
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

Author
7 Feb 2006 7:13 AM
Cor Ligthert [MVP]
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
Author
7 Feb 2006 11:53 AM
Bart Mermuys
Hi,

"Phil Williams" <Phillandsa***@hotmail.com> wrote in message
news:eltqOq5KGHA.1568@TK2MSFTNGP10.phx.gbl...
> 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

Show quote
>
>
> Thanks in Advance
> Phil
>
Author
8 Feb 2006 1:53 AM
Phil Williams
Thanks, it is soo easy when you know how!

Thanks again,
Phil

Show quote
"Bart Mermuys" <bmermuys.nospam@hotmail.com> wrote in message
news:e0f1o09KGHA.3164@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> "Phil Williams" <Phillandsa***@hotmail.com> wrote in message
> news:eltqOq5KGHA.1568@TK2MSFTNGP10.phx.gbl...
>> 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
>
>>
>>
>> Thanks in Advance
>> Phil
>>
>
>

AddThis Social Bookmark Button