DataBinding ...(长) [英] DataBinding... (long)

查看:75
本文介绍了DataBinding ...(长)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

公共类Xxx

{

private string tableName =""


public string TableName

{

get {return this.tableName;}

set

{

if(value != null)

{

this.tableName = value.Trim()

}

else

{

this.tableName =""

}

}

}

}


Xxx xxx =新Xxx();


scanario是:

我有一个MdiContainer Form1,我正在显示MdiChilds。

在每个子窗体上我都将TextBox Text属性绑定到

属性传递给子表单构造函数的xxx表名称

作为参考。


私有Xxx xxx;


/ /构造函数

public FormChild(ref pXxx)

{

this.xxx = pXxx;

}


受保护覆盖​​OnLoad(...)

{

this.TaxtBo x0.DataBindings.Add(" Text",this.xxx," Ta bleName");

}


每次(第一次旁边) )ChildForm显示我有一个探测器

在更改TextBox0文本后在其(ChildForm)控件之间移动。

换句话说,如果我更改TextBox0的文本我必须在保存按钮(或表单上的任何其他控件)上单击2或3次

才能获得此按钮

点击

或任何控制动作都可以执行。


没有DataBinding它可以正常工作。如果Child表单不是
,它也可以正常工作从MdiParent作为MdiChild调用

,但只是以模态形式运行。


那么什么是错的?


在MdiParentForm上显示ChildForm的代码是:


ChildForm child = new ChildForm(ref xxx);

child.MdiParent = this。

this.contentPanel.Controls.Add(child)

child.Dock = DockStyle.Fill;

child.Show();


CleanupCode是:


child.Close();

child.Dispose();

child = null;

我认为DataBinding在一般情况下有一些问题...每次使用

我正在解决一些问题和不稳定因素。我在其他程序员看到

考试在gotdotnet和其他tey没有使用DataBinding和

useng LoadData()和SaveData()方法来简单地获取和设置propertys

对象如:


LoadData()

{

this.TextBox0.text = this。 xxx.TableName;

}


SaveData()

{

this.xxx.TableName = this.TextBox0.Text;

}


但我在我的属性实现中有一些控件,如果价值

已更正我希望用户在保存哪个场景之前看到它

以上不符合。

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.

推荐答案

还有一件事......

如果你用

替换我的控件标准Windows窗体的一切

完美运行......
One thing more...
If You replace my controls with
standard Windows Forms everything
works perfectly...


经过长时间的战斗后我发现了一个bug ...


DCTextBox.Text property.Set


base.Text = value.Trim();


修剪导致挂起。我不知道为什么

但是没有Trim()它工作得很好...... :-)
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... :-)


你好Jacek,

我收到你的项目,我会花一些时间,我会尽快给你回复




感谢您的理解。


祝你好运,

Jeffrey Tan

Microsoft在线合作伙伴支持

安全! - www.microsoft.com/security

此帖子按原样提供没有保证,也没有赋予任何权利。
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.


这篇关于DataBinding ...(长)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆