Click here to Skip to main content
15,921,454 members
Home / Discussions / C#
   

C#

 
AnswerRe: [StructLayout(LayoutKind.Sequential)] Pin
0x3c017-Jan-10 5:45
0x3c017-Jan-10 5:45 
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 
ArjenGroeneveld wrote:
Okay, Can you help me with the code?


If you want to save the Dirty-field along with the binding, then I'd suggest overriding the Binding class, and not the BindingSource. This might give you a start for a test-form, and having a property in a derived class, using databinding;
using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;

namespace Example
{
	public class MyBinding : Binding
	{
		bool _isDirty;
		public bool IsDirty
		{
			get
			{
				return _isDirty;
			}
			set
			{
				if (_isDirty != value)
					_isDirty = value;
			}
		}
		
		public MyBinding(string propertyName, object DataSource, string dataMember)
			:base(propertyName, DataSource, dataMember)
		{
			// more stuff!!
		}
	}
	
	public class Form1 : System.Windows.Forms.Form 
	{
		static void Main() 
		{
			Application.Run(new Form1());
		}
		
		private TextBox textBox1;
		private ListBox listBox1;
		private MyBinding myBinding;
		
		public Form1() 
		{
			InitializeComponent();
		}
	
		private void InitializeComponent()
		{
			SuspendLayout();
			listBox1 = new ListBox();
			textBox1 = new TextBox();
	
			textBox1.Location = new Point(16, 68);
			textBox1.Size = new Size(144, 20);		
			
			listBox1.Location = new Point(16, 8);
			listBox1.Size = new Size(144, 50);

			ClientSize = new Size(176, 100);
			Controls.Add(textBox1);
			Controls.Add(listBox1);
				
			Name = "Form1";
			Text = "Form1";
			Load += new EventHandler(Form1_Load);
			ResumeLayout(false);
		}		
		
		private void Form1_Load(object sender, System.EventArgs e) 
		{
			DataTable dt = new DataTable("employee");
			dt.Columns.Add("firstname");
			dt.Columns.Add("lastname");
			dt.Rows.Add("john", "doe");
			dt.Rows.Add("johnny", "walker");		
			
			listBox1.DataSource = dt;
			listBox1.DisplayMember = "firstname";

			myBinding = new MyBinding("Text", listBox1.DataSource, "lastname");
			textBox1.DataBindings.Add(myBinding);
		}
	}
}
Enjoy Smile | :)

I are Troll Suspicious | :suss:

GeneralRe: Extend BindingSource with a Dirty property and Dirty changed Event Pin
ArjenGroeneveld17-Jan-10 21:24
ArjenGroeneveld17-Jan-10 21:24 
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 

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.