PC Review


Reply
Thread Tools Rate Thread

DataGrid detect row changes

 
 
Doug Bell
Guest
Posts: n/a
 
      14th Feb 2007
Hi
I have a DataGrid that has a DataView as its DataSource.

I need to detect when a New Row is added or when a Row is Deleted so that I
change data in the underlying DataTable.

I found that MyDataGrid_CurrentCellChanged doesn't fire on a deletion or on
a New Row if there was no previous rows.

Can someone advised the simplest way to detect row additions or deletions?

Thanks


 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      14th Feb 2007
Doug

As you are working witht he datagrid, try than to forget change information
from that, try to use the underlying datasource. A change in the datagrid is
not as something is typed (or you should use the textbox for that), however
if there is a rowchange.

It is just more simple to work with the datasource than the cells from the
datagrid.

Cor

"Doug Bell" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> Hi
> I have a DataGrid that has a DataView as its DataSource.
>
> I need to detect when a New Row is added or when a Row is Deleted so that
> I
> change data in the underlying DataTable.
>
> I found that MyDataGrid_CurrentCellChanged doesn't fire on a deletion or
> on
> a New Row if there was no previous rows.
>
> Can someone advised the simplest way to detect row additions or deletions?
>
> Thanks
>
>



 
Reply With Quote
 
Doug Bell
Guest
Posts: n/a
 
      14th Feb 2007
OK but how do I get a change in the underlying DataTable to trigger an Event
that I can use check and set the (complex) "ID" Column in the DataTable for
the New Row.


"Cor Ligthert [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Doug
>
> As you are working witht he datagrid, try than to forget change

information
> from that, try to use the underlying datasource. A change in the datagrid

is
> not as something is typed (or you should use the textbox for that),

however
> if there is a rowchange.
>
> It is just more simple to work with the datasource than the cells from the
> datagrid.
>
> Cor
>
> "Doug Bell" <(E-Mail Removed)> schreef in bericht
> news:(E-Mail Removed)...
> > Hi
> > I have a DataGrid that has a DataView as its DataSource.
> >
> > I need to detect when a New Row is added or when a Row is Deleted so

that
> > I
> > change data in the underlying DataTable.
> >
> > I found that MyDataGrid_CurrentCellChanged doesn't fire on a deletion or
> > on
> > a New Row if there was no previous rows.
> >
> > Can someone advised the simplest way to detect row additions or

deletions?
> >
> > Thanks
> >
> >

>
>



 
Reply With Quote
 
ClayB
Guest
Posts: n/a
 
      14th Feb 2007
Try listening to the underly DataView.ListChanged event. (If the
DataSource is a DataTable, this would probably be
DataTable.DefaultView). There you can check for:

if(e.ListChangedType == ListChangedType.ItemAdded)
{
//...
}

Maybe this will picked out the adding of a new row.

================
Clay Burch
Syncfusion, Inc.

 
Reply With Quote
 
ClayB
Guest
Posts: n/a
 
      14th Feb 2007
Oops. Sorry for the C# code.

If e.ListChangedType = ListChangedType.ItemAdded Then
'...
End If
====================
Clay Burch
Syncfusion, Inc.

 
Reply With Quote
 
Doug Bell
Guest
Posts: n/a
 
      14th Feb 2007
Thanks

got it

Doug

"ClayB" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Oops. Sorry for the C# code.
>
> If e.ListChangedType = ListChangedType.ItemAdded Then
> '...
> End If
> ====================
> Clay Burch
> Syncfusion, Inc.
>



 
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
Detect when datagrid is modified =?Utf-8?B?RG90bmV0anVua3k=?= Microsoft Dot NET Framework Forms 3 14th Sep 2006 07:32 PM
How to detect datagrid row change Brian Tkatch Microsoft VB .NET 2 26th Jun 2006 08:43 PM
detect row selected in datagrid Rod Microsoft Dot NET Framework Forms 0 17th Jun 2005 10:40 AM
detect eof on datagrid starbuck Microsoft VB .NET 6 19th Mar 2004 12:17 AM
how detect selected line in datagrid Rafael Metring Microsoft Dot NET Compact Framework 2 26th Feb 2004 02:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:00 AM.