More Bindings

  • Thread starter Thread starter Chuck Bowling
  • Start date Start date
C

Chuck Bowling

I have a typed collection bound to some form components. When information in
the dataset changes I want to mark it as dirty so that I can save it when
the form closes. The BindingManager.CurrentChanged event looks like the
perfect place to do this but it turns out that CurrentChanged also fires
when ever BindingManager.Position changes. I'm not interested in Position
changes. Only in actual changes in the data. Is there an easy way to track
changes to bound datarows or do I also have to detect changes in Position so
that I can ignore them?
 
Chuck,

The binding is not the place to do this. Rather, when you want to check
if the dataset is dirty, just call the HasChanges method on the DataSet (or
DataTable), and it will inform you if any changes have been made to it.

Hope this helps.
 
Thank you Nicholas. The problem is that this isn't a real dataset. It's a
typed collection derived from CollectionBase (My fault for calling it a
dataset. Sorry).

Unless I'm missing something, CollectionBase doesn't have a HasChanges
method. Basically, that's the method I'd like to implement.

Nicholas Paldino said:
Chuck,

The binding is not the place to do this. Rather, when you want to
check if the dataset is dirty, just call the HasChanges method on the
DataSet (or DataTable), and it will inform you if any changes have been
made to it.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Chuck Bowling said:
I have a typed collection bound to some form components. When information
in the dataset changes I want to mark it as dirty so that I can save it
when the form closes. The BindingManager.CurrentChanged event looks like
the perfect place to do this but it turns out that CurrentChanged also
fires when ever BindingManager.Position changes. I'm not interested in
Position changes. Only in actual changes in the data. Is there an easy way
to track changes to bound datarows or do I also have to detect changes in
Position so that I can ignore them?
 
Chuck,

In this case, I would have the collection keep track of it, and not use
the binding manager. The reason for this is that more than one binding can
be made on the collection, and it won't really help you.

Basically, you would have to have some mechanism by which the collection
was notified of the changes in it's items. Most likely, an event would be
what you want.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Chuck Bowling said:
Thank you Nicholas. The problem is that this isn't a real dataset. It's a
typed collection derived from CollectionBase (My fault for calling it a
dataset. Sorry).

Unless I'm missing something, CollectionBase doesn't have a HasChanges
method. Basically, that's the method I'd like to implement.

Nicholas Paldino said:
Chuck,

The binding is not the place to do this. Rather, when you want to
check if the dataset is dirty, just call the HasChanges method on the
DataSet (or DataTable), and it will inform you if any changes have been
made to it.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Chuck Bowling said:
I have a typed collection bound to some form components. When information
in the dataset changes I want to mark it as dirty so that I can save it
when the form closes. The BindingManager.CurrentChanged event looks like
the perfect place to do this but it turns out that CurrentChanged also
fires when ever BindingManager.Position changes. I'm not interested in
Position changes. Only in actual changes in the data. Is there an easy
way to track changes to bound datarows or do I also have to detect
changes in Position so that I can ignore them?
 
Thank you for the advice Nicholas. I was thinking something along the same
lines but was hoping that there might be some built in mechanism I could
use.

Nicholas Paldino said:
Chuck,

In this case, I would have the collection keep track of it, and not use
the binding manager. The reason for this is that more than one binding
can be made on the collection, and it won't really help you.

Basically, you would have to have some mechanism by which the
collection was notified of the changes in it's items. Most likely, an
event would be what you want.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Chuck Bowling said:
Thank you Nicholas. The problem is that this isn't a real dataset. It's a
typed collection derived from CollectionBase (My fault for calling it a
dataset. Sorry).

Unless I'm missing something, CollectionBase doesn't have a HasChanges
method. Basically, that's the method I'd like to implement.

Nicholas Paldino said:
Chuck,

The binding is not the place to do this. Rather, when you want to
check if the dataset is dirty, just call the HasChanges method on the
DataSet (or DataTable), and it will inform you if any changes have been
made to it.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I have a typed collection bound to some form components. When
information in the dataset changes I want to mark it as dirty so that I
can save it when the form closes. The BindingManager.CurrentChanged
event looks like the perfect place to do this but it turns out that
CurrentChanged also fires when ever BindingManager.Position changes. I'm
not interested in Position changes. Only in actual changes in the data.
Is there an easy way to track changes to bound datarows or do I also
have to detect changes in Position so that I can ignore them?
 
Back
Top