HighTechTalks DotNet Forums  

Can I bind a control to a dataset.haschanges property?

Dotnet General Discussions microsoft.public.dotnet.general


Discuss Can I bind a control to a dataset.haschanges property? in the Dotnet General Discussions forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
John
 
Posts: n/a

Default Can I bind a control to a dataset.haschanges property? - 12-05-2007 , 06:03 AM






Hello,

I was wondering if it was possibly to bind a control to a dataset.haschanges
property.

The reason I want to do this is so that a little warning shows up on the
form saying that the record has not been saved.

Thank you heaps for anyones thoughts
John Sheppard



Reply With Quote
  #2  
Old   
W.G. Ryan
 
Posts: n/a

Default Re: Can I bind a control to a dataset.haschanges property? - 12-05-2007 , 02:28 PM






Well, not directly. HasChanges is a method not a property so while it seems
pedantic, it is the reason it won't work. If you really needed thsi
functionality, you could create a property that simply wrapped the call to
HasChanges and bind to it instead but it would need to be subclassed. (note,
I have not specifically done this but since you can bind to other
properites, I'm 99.9% sure you'd be fine if you created a property of your
own.)
"John" <nospam (AT) nospam (DOT) com> wrote

Quote:
Hello,

I was wondering if it was possibly to bind a control to a
dataset.haschanges property.

The reason I want to do this is so that a little warning shows up on the
form saying that the record has not been saved.

Thank you heaps for anyones thoughts
John Sheppard




Reply With Quote
  #3  
Old   
W.G. Ryan
 
Posts: n/a

Default Re: Can I bind a control to a dataset.haschanges property? - 12-05-2007 , 02:33 PM



John:

I just went ahead and did it...
For the whole "Untyped" thing, you can just deal with this class like you
would any other dataset and if you created a typed dataset you could do the
same:

namespace WindowsApplication2

{

public class AugmentedDataSet : DataSet

{

private Boolean hasChanged;

public Boolean HasChanged

{

get { return base.HasChanges(); }

set { hasChanged = value; }

}


}

}



Now here's the binding code:



"John" <nospam (AT) nospam (DOT) com> wrote

Quote:
Hello,

I was wondering if it was possibly to bind a control to a
dataset.haschanges property.

The reason I want to do this is so that a little warning shows up on the
form saying that the record has not been saved.

Thank you heaps for anyones thoughts
John Sheppard




Reply With Quote
  #4  
Old   
W.G. Ryan
 
Posts: n/a

Default Re: Can I bind a control to a dataset.haschanges property? - 12-05-2007 , 02:33 PM



Ooops, I think I forgot to send this

private void Form1_Load(object sender, EventArgs e)

{

AugmentedDataSet ds = new AugmentedDataSet();


ds.Tables.Add(new DataTable("WhateverTable"));

ds.Tables[0].Columns.Add(new DataColumn("MyColumn", typeof(String)));

chkHasChanges.DataBindings.Add("Checked", ds.HasChanged, null);

}



Coupled with my last post, this should do it for you

"John" <nospam (AT) nospam (DOT) com> wrote

Quote:
Hello,

I was wondering if it was possibly to bind a control to a
dataset.haschanges property.

The reason I want to do this is so that a little warning shows up on the
form saying that the record has not been saved.

Thank you heaps for anyones thoughts
John Sheppard




Reply With Quote
  #5  
Old   
John Sheppard
 
Posts: n/a

Default Re: Can I bind a control to a dataset.haschanges property? - 12-10-2007 , 12:19 AM



Thanks Ryan,

Sorry for the slow response...I shall try this out...looks good...Thank you
so much for spending the time to trial it out for me.

Kind regards
John Sheppard

"W.G. Ryan" <WilliamRyan (AT) nospam (DOT) gmail.com> wrote

Quote:
Ooops, I think I forgot to send this

private void Form1_Load(object sender, EventArgs e)

{

AugmentedDataSet ds = new AugmentedDataSet();


ds.Tables.Add(new DataTable("WhateverTable"));

ds.Tables[0].Columns.Add(new DataColumn("MyColumn", typeof(String)));

chkHasChanges.DataBindings.Add("Checked", ds.HasChanged, null);

}



Coupled with my last post, this should do it for you

"John" <nospam (AT) nospam (DOT) com> wrote in message
news:fj60ok02jn0 (AT) news5 (DOT) newsguy.com...
Hello,

I was wondering if it was possibly to bind a control to a
dataset.haschanges property.

The reason I want to do this is so that a little warning shows up on the
form saying that the record has not been saved.

Thank you heaps for anyones thoughts
John Sheppard






Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.