Click here to Skip to main content
15,906,341 members
Home / Discussions / C#
   

C#

 
AnswerRe: [StructLayout(LayoutKind.Sequential)] Pin
dan!sh 17-Jan-10 6:12
professional dan!sh 17-Jan-10 6:12 
AnswerRe: [StructLayout(LayoutKind.Sequential)] Pin
harold aptroot17-Jan-10 6:28
harold aptroot17-Jan-10 6:28 
AnswerRe: [StructLayout(LayoutKind.Sequential)] Pin
DaveyM6917-Jan-10 7:32
professionalDaveyM6917-Jan-10 7:32 
QuestionExtend BindingSource with a Dirty property and Dirty changed Event Pin
ArjenGroeneveld17-Jan-10 5:20
ArjenGroeneveld17-Jan-10 5:20 
AnswerRe: Extend BindingSource with a Dirty property and Dirty changed Event Pin
Eddy Vluggen17-Jan-10 10:11
professionalEddy Vluggen17-Jan-10 10:11 
GeneralRe: Extend BindingSource with a Dirty property and Dirty changed Event Pin
ArjenGroeneveld17-Jan-10 10:38
ArjenGroeneveld17-Jan-10 10:38 
GeneralRe: Extend BindingSource with a Dirty property and Dirty changed Event Pin
Eddy Vluggen17-Jan-10 13:44
professionalEddy Vluggen17-Jan-10 13:44 
GeneralRe: Extend BindingSource with a Dirty property and Dirty changed Event Pin
ArjenGroeneveld17-Jan-10 21:24
ArjenGroeneveld17-Jan-10 21:24 
Hello,

The end result I have in mind is an extended BindingSouce control, which is having an "IsDirty" property and an "IsDirtyChange" event.
The "IsDirtyChange" should only trigger when the User is making a change in one of the bounded controls.

I did some searching in FrameWork and I put the following together, but this code does not trigger when a user changes the content in a control. So something is missing.

Extended BindingSource coding...
namespace ACMAD.Business
{
class exBindingSource : BindingSource
{
// Internal variable
private bool flgIsDirty = false;

// Event
public event EventHandler IsDirtyChanged;

protected virtual void OnDirtyChanged(EventArgs e)
{
if (IsDirtyChanged != null)
{
IsDirtyChanged(this, e);
}
}

public bool IsDirty
{
get
{
return flgIsDirty;
}
set
{
flgIsDirty = value;
}
}

protected override void OnBindingComplete(BindingCompleteEventArgs e)
{
base.OnBindingComplete(e);

if (e.BindingCompleteContext == BindingCompleteContext.DataSourceUpdate)
{
if (!flgIsDirty && (e.BindingCompleteState == BindingCompleteState.Success) && e.Binding.Control.Focused)
{
flgIsDirty = true;
OnDirtyChanged(EventArgs.Empty);
}
}
}

protected override void OnCurrentChanged(EventArgs e)
{
base.OnCurrentChanged(e);
if (flgIsDirty == true)
flgIsDirty = false;
}
}
}

Form coding
I placed the exBindingSource on the form and connected an textbox to it.
One record is loaded with:

// Test purpose
exBindingSource1.Clear();
exBindingSource1.Add(ac_Model);


And I added an event
private void exBindingSource1_IsDirtyChanged(object sender, EventArgs e)
{
textBox1.Text = exBindingSource1.IsDirty.ToString();
}


The idea is that when the user makes a change to Textbox1 that Textbox2 is filled with the exBindingSource1.IsDirty value.

But ... nothing happens..

Your help is most appreciated.

With kind regards,
Arjen Groeneveld
GeneralRe: Extend BindingSource with a Dirty property and Dirty changed Event Pin
Eddy Vluggen18-Jan-10 11:12
professionalEddy Vluggen18-Jan-10 11:12 
GeneralRe: Extend BindingSource with a Dirty property and Dirty changed Event Pin
sarapkamikazee1524-Aug-10 6:05
sarapkamikazee1524-Aug-10 6:05 
QuestionEmpty rows in daatagrid Pin
tasossty17-Jan-10 4:50
tasossty17-Jan-10 4:50 
AnswerRe: Empty rows in daatagrid Pin
Eddy Vluggen17-Jan-10 9:29
professionalEddy Vluggen17-Jan-10 9:29 
QuestionC# C++ Java performance comparison Pin
devvvy17-Jan-10 3:47
devvvy17-Jan-10 3:47 
AnswerRe: C# C++ Java performance comparison Pin
EliottA17-Jan-10 4:08
EliottA17-Jan-10 4:08 
AnswerRe: C# C++ Java performance comparison Pin
Luc Pattyn17-Jan-10 4:33
sitebuilderLuc Pattyn17-Jan-10 4:33 
AnswerRe: C# C++ Java performance comparison Pin
N a v a n e e t h17-Jan-10 4:34
N a v a n e e t h17-Jan-10 4:34 
AnswerRe: C# C++ Java performance comparison Pin
harold aptroot17-Jan-10 4:53
harold aptroot17-Jan-10 4:53 
GeneralRe: C# C++ Java performance comparison Pin
devvvy19-Jan-10 19:14
devvvy19-Jan-10 19:14 
GeneralRe: C# C++ Java performance comparison Pin
harold aptroot20-Jan-10 1:17
harold aptroot20-Jan-10 1:17 
Questionerrors pls help..... Pin
djsproject17-Jan-10 2:02
djsproject17-Jan-10 2:02 
QuestionMessage Removed Pin
17-Jan-10 1:03
sachees12317-Jan-10 1:03 
AnswerRe: very special problem Pin
Dan Mos17-Jan-10 1:51
Dan Mos17-Jan-10 1:51 
GeneralRe: very special problem Pin
sachees12317-Jan-10 2:01
sachees12317-Jan-10 2:01 
GeneralRe: very special problem Pin
Dan Mos17-Jan-10 2:51
Dan Mos17-Jan-10 2:51 
GeneralRe: very special problem Pin
sachees12317-Jan-10 2:11
sachees12317-Jan-10 2:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.