PC Review


Reply
Thread Tools Rate Thread

Identify selected row in the DataGrids underlying datatable...

 
 
Trygve Lorentzen
Guest
Posts: n/a
 
      17th Mar 2004
Hi,

I need to identify which row is selected in a DataGrid bound to a DataTable.
How do I do this, I'm pretty lost atm and need to make a demo work for
tomorrow. Please help...

Cheers,
Trygve


 
Reply With Quote
 
 
 
 
Trygve Lorentzen
Guest
Posts: n/a
 
      17th Mar 2004
Forgot to mention that this a Windows App and that it doesn't really matter
how I do this as long as I get the Primary key column(s) of the row that is
currently selected (or clicked).

"Trygve Lorentzen" <trygveloAThaldenDOTnet> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I need to identify which row is selected in a DataGrid bound to a

DataTable.
> How do I do this, I'm pretty lost atm and need to make a demo work for
> tomorrow. Please help...
>
> Cheers,
> Trygve
>
>



 
Reply With Quote
 
William Ryan eMVP
Guest
Posts: n/a
 
      17th Mar 2004
Trygve:

You can trap the DataGrid.CurrentCell. CurrentCell has a RowIndex and a
ColumnIndex.

Then, you can use dg.Item(CurrentRowIndex, PrimaryKeyIndex)
"Trygve Lorentzen" <trygveloAThaldenDOTnet> wrote in message
news:eLj#(E-Mail Removed)...
> Forgot to mention that this a Windows App and that it doesn't really

matter
> how I do this as long as I get the Primary key column(s) of the row that

is
> currently selected (or clicked).
>
> "Trygve Lorentzen" <trygveloAThaldenDOTnet> wrote in message
> news:(E-Mail Removed)...
> > Hi,
> >
> > I need to identify which row is selected in a DataGrid bound to a

> DataTable.
> > How do I do this, I'm pretty lost atm and need to make a demo work for
> > tomorrow. Please help...
> >
> > Cheers,
> > Trygve
> >
> >

>
>



 
Reply With Quote
 
Trygve Lorentzen
Guest
Posts: n/a
 
      17th Mar 2004
Thanks for the solution, I guess this is a stupid question, but can I use
any method in the DataTable class to determine what row is currently
selected too? Just like the CurrentCell property of the DataGrid... I
suppose not anyway... It doesn't make sense except for when you loop through
the rows of the datatable in code.

Trygve

"William Ryan eMVP" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Trygve:
>
> You can trap the DataGrid.CurrentCell. CurrentCell has a RowIndex and a
> ColumnIndex.
>
> Then, you can use dg.Item(CurrentRowIndex, PrimaryKeyIndex)
> "Trygve Lorentzen" <trygveloAThaldenDOTnet> wrote in message
> news:eLj#(E-Mail Removed)...
> > Forgot to mention that this a Windows App and that it doesn't really

> matter
> > how I do this as long as I get the Primary key column(s) of the row that

> is
> > currently selected (or clicked).
> >
> > "Trygve Lorentzen" <trygveloAThaldenDOTnet> wrote in message
> > news:(E-Mail Removed)...
> > > Hi,
> > >
> > > I need to identify which row is selected in a DataGrid bound to a

> > DataTable.
> > > How do I do this, I'm pretty lost atm and need to make a demo work for
> > > tomorrow. Please help...
> > >
> > > Cheers,
> > > Trygve
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
William Ryan eMVP
Guest
Posts: n/a
 
      18th Mar 2004
Trygve:

Unfortunately, a row isn't Selected as such b/c "Selected" is a visual
thing. However, You've got TONS more functionality as far as finding and
referencing things with a DataTable than you do with a grid.

Can you tell me ultimately what you want to do? There's a RowChanging Event
that may be of use, and you can directly reference the rows
DataTable.Rows[WhateverIndex], use Select, Compute and all sorts of other
methods. Let me know that goal and I'll see what I can do.

Cheers,

Bill
"Trygve Lorentzen" <trygveloAThaldenDOTnet> wrote in message
news:%(E-Mail Removed)...
> Thanks for the solution, I guess this is a stupid question, but can I use
> any method in the DataTable class to determine what row is currently
> selected too? Just like the CurrentCell property of the DataGrid... I
> suppose not anyway... It doesn't make sense except for when you loop

through
> the rows of the datatable in code.
>
> Trygve
>
> "William Ryan eMVP" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Trygve:
> >
> > You can trap the DataGrid.CurrentCell. CurrentCell has a RowIndex and a
> > ColumnIndex.
> >
> > Then, you can use dg.Item(CurrentRowIndex, PrimaryKeyIndex)
> > "Trygve Lorentzen" <trygveloAThaldenDOTnet> wrote in message
> > news:eLj#(E-Mail Removed)...
> > > Forgot to mention that this a Windows App and that it doesn't really

> > matter
> > > how I do this as long as I get the Primary key column(s) of the row

that
> > is
> > > currently selected (or clicked).
> > >
> > > "Trygve Lorentzen" <trygveloAThaldenDOTnet> wrote in message
> > > news:(E-Mail Removed)...
> > > > Hi,
> > > >
> > > > I need to identify which row is selected in a DataGrid bound to a
> > > DataTable.
> > > > How do I do this, I'm pretty lost atm and need to make a demo work

for
> > > > tomorrow. Please help...
> > > >
> > > > Cheers,
> > > > Trygve
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A DataTable-bound DataGridView throws a low-level Exception whencolumns are sorted, removed and re-added to the underlying DataTable. Sath123 Microsoft Dot NET Framework Forms 1 12th May 2008 01:51 PM
Identify Underlying OS Platform? Mahmoud Al-Qudsi Microsoft C# .NET 1 29th Apr 2007 11:45 PM
Select the row in datagrid based on the row updated in underlying datatable BijuP Microsoft VB .NET 0 18th May 2006 10:14 AM
how to set the same datatable as the data source for two separate datagrids in a form LeAnne Microsoft VB .NET 1 31st Dec 2005 09:21 AM
How to select known DataRow from underlying DataTable on DataGrid (WinForms) Bajgon Microsoft C# .NET 2 6th Dec 2004 05:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:59 AM.