PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET ADO.NET 2.0 - Get the value current record using the DataGridView

Reply

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

 
Thread Tools Rate Thread
Old 07-02-2006, 03:57 AM   #1
Phil Williams
Guest
 
Posts: n/a
Default ADO.NET 2.0 - Get the value current record using the DataGridView


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


  Reply With Quote
Old 07-02-2006, 07:13 AM   #2
Cor Ligthert [MVP]
Guest
 
Posts: n/a
Default Re: ADO.NET 2.0 - Get the value current record using the DataGridView

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


  Reply With Quote
Old 07-02-2006, 11:53 AM   #3
Bart Mermuys
Guest
 
Posts: n/a
Default Re: ADO.NET 2.0 - Get the value current record using the DataGridView

Hi,

"Phil Williams" <Phillandsarah@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
>



  Reply With Quote
Old 08-02-2006, 01:53 AM   #4
Phil Williams
Guest
 
Posts: n/a
Default Re: ADO.NET 2.0 - Get the value current record using the DataGridView

Thanks, it is soo easy when you know how!

Thanks again,
Phil

"Bart Mermuys" <bmermuys.nospam@hotmail.com> wrote in message
news:e0f1o09KGHA.3164@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> "Phil Williams" <Phillandsarah@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
>>

>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off