DataBinding... (long)

J

Jacek Jurkowski

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,"TableName");
}

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.
 
J

Jacek Jurkowski

One thing more...
If You replace my controls with
standard Windows Forms everything
works perfectly...
 
J

Jacek Jurkowski

After a long fight I found a bug...

DCTextBox.Text property.Set

base.Text = value.Trim();

Trim causes the hangs. I don't know why
but without Trim() it works fine... :)
 
J

Jeffrey Tan[MSFT]

Hi Jacek,

I have received your project, I will spend some time on it, I will reply to
you ASAP.

Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Jacek,

Sorry for letting you wait for so long time.

After viewing your code, I found that the problem is just the String.Trim
method, just as you stated.

To workaround it, you may just do like this in "get" accessor:

get
{
string s=base.Text.Trim();
return s;
}

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Jacek,

Thanks very much for your feedback.

For your further issue, you may bring the child form to the front through
invoking:

Panel.SendToBack()

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Jacek,

Does my reply work for you? Do you still have any concern on this issue?

Please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jacek Jurkowski

Jeffrey...

There is a MDIClient control in a Form1 of my example.
The problem is that MDIClient is independent to other
controls of the form. So Client forms are displayed in
MDIClient control but other controls (like tree view
and panel in my example are created in a form itself) So if
i would like to make my child form visible i have to
bring MDIClient to the front covering other form controls.
If i bring forms controls it covers MDIClient and my child
form ... madnaess!
There is no wey out because i can't add forms controls to
a MDIClient ...
 
J

Jeffrey Tan[MSFT]

Hi Jacek,

Thanks for your feedback.

I think we need not to send the Panel to back. I think you missed one code
statement in Child2 selection. If you add the fC2 in the child controls
collection of contentPanel, fC2 should appear. This works well:

case "Child2":
{
Child2 fC2 = new Child2();
fC2.MdiParent=this;
this.contentPanel.Controls.Add(fC2);

fC2.Show();

MessageBox.Show("Resume?");

break;
}

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jacek Jurkowski

Yes ... it works ok but it's not perfect ...
I will'use it because I have no alternative...
Thank's Jeffrey :)
 
J

Jeffrey Tan[MSFT]

Hi Jeffrey,

I am glad I can help you :). You are welcome!!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DataBinding ... (long) 1

Top