GroupBox BindingContext [英] GroupBox BindingContext

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

问题描述

您好,我正在尝试为网上论坛提供一个自己的货币管理器.问题在于,当我创建一个新的bindingContext并将其分配给一个groupbox时,绑定的文本框将无法显示任何数据(如果我保留表单的绑定上下文,它们将显示数据).

当为文本框的容器控件分配新的bindingContext时,为什么这些文本框根本不显示数据?

我认为正在为每个组框创建货币管理器,但文本框似乎不再受约束.

Hi, I am trying to give a groupbox its own currency manager. The problem is that when I create a new bindingContext and assign it to a groupbox, the bound textboxes fail to show any data (they do display data if I keep the form''s binding context).

Why would the textboxes not display data at all when their container control is assigned a new bindingContext?

I think the currencymanager is being created for each groupbox, but the textbox no longer seem to be bound.

private void BindControls()
{
   BindingContext bcG1 = new BindingContext();
   BindingContext bcG2 = new BindingContext();
   groupBox1.BindingContext = bcG1;
   groupBox2.BindingContext = bcG2;
   textBox1.DataBindings.Add("Text", ds, "Customers.CustName");
   textBox2.DataBindings.Add("Text", ds, "Customers.CustName");
}
private void Button1_Click(object sender, EventArgs e)
{
   groupBox1.BindingContext[ds, "Customers"].Position += 1;         
}
private void Button2_Click(object sender, EventArgs e)
{
   groupBox2.BindingContext[ds, "Customers"].Position += 1;
}





Thanks

推荐答案

为什么要为两个组框维护单独的currencymanager?在窗体上共享其他数据源的表单上是否还有其他控件?如果每个GroupBox控件都有自己的CurrencyManager对象对于客户数据源,更改一个位置属性不会更改另一个.

VB.Net中在这里提到了一种解决方法.将其转换为C#&申请

pdf页面148

http://www.bluevisionsoftware.com/WebSite/Books/0972317929/Ch06.pdf [ ^ ]
Why do you want to maintain separate currencymanager for both groupboxes?Do you have other controls on form sharing same datasource?If each GroupBox control has its own CurrencyManager object for the Customers data source,changing position property of one doesnt change the other.

There is a workaround mentioned here in VB.Net . Convert it to C# & apply

Page 148 of this pdf

http://www.bluevisionsoftware.com/WebSite/Books/0972317929/Ch06.pdf[^]


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

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