public class Xxx
{
private string tableName = ""
public string TableName
{
get{return this.tableName;}
set
{
if(value != null)
{
this.tableName = value.Trim()
}
else
{
this.tableName = ""
}
}
}
}
Xxx xxx = new Xxx();
The scanario is:
I have a MdiContainer Form1 and I'm displaying MdiChilds in it.
On every child form I'm binding a TextBox Text property to a
property TableName of xxx passed to a child forms constructor
as an reference.
private Xxx xxx;
// Constructor
public FormChild(ref pXxx)
{
this.xxx = pXxx;
}
protected override OnLoad(...)
{
this.TaxtBox0.DataBindings.Add("Text",this.xxx,"Ta bleName");
}
Every time (beside the first time) the ChildForm is showing I have a probem
to move between its (ChildForm) controls after changing Text of TextBox0.
In other words if i change Text of my TextBox0 i have to click 2 or 3 times
on a save button (or any other control on the form) to get this button
clicked
or any control action perform.
Without DataBinding it works ok. It works ok also if Child form is not
called
from MdiParent as MdiChild but simply run as a modal form.
So what's wrong?
The code displaying ChildForm on MdiParentForm is:
ChildForm child = new ChildForm(ref xxx);
child.MdiParent = this.
this.contentPanel.Controls.Add(child)
child.Dock = DockStyle.Fill;
child.Show();
CleanupCode is:
child.Close();
child.Dispose();
child = null;
I think that DataBinding has some problem in general... Every time I use
it i'm geting some problems and instabilities. I saw in other programists
examles on gotdotnet and other that tey are not using DataBinding and
useng LoadData() and SaveData() methods to simply get and set propertys
of objects like:
LoadData()
{
this.TextBox0.text = this.xxx.TableName;
}
SaveData()
{
this.xxx.TableName = this.TextBox0.Text;
}
But I've got some controls in my propertys implementation and if value
is corrected I would like to user saw it before saving which scenario
above doesn't meet.