选项卡和组合框重新发布 [英] Tabs and ComboBoxes Repost

查看:66
本文介绍了选项卡和组合框重新发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的本地

应用程序启动时,如何保持ComboBox文本框中没有数据源项目,即使用户在表单上单击不同的

选项卡,也保持空白。


我欢迎任何问题。问题是从CB

文本框中清除项目,问题是当用户四处移动时我无法保持空白

Tabs on the形成。每个Tab都有更多CBa ?? s,当然,我需要在每个Tab上保留用户CB选项。


我想我可以通过向CB数据源添加空格来解决问题

(dB表/数据集)。我是否需要每个CB的Leave()事件和变量?标签

活动?建议欢迎。我不能放过这个。


上一篇文章
http:// www .microsoft.com / communities ... 200& sloc = en-us

How can I keep the ComboBox textbox empty of datasource items when my local
application starts AND keep them empty even after the user clicks different
Tabs on the form.

I welcome any questions. The problem isna??t clearing the items from the CB
textbox, the problem is I cana??t keep them empty when the user moves around
the Tabs on the form. Each Tab has more CBa??s and, by the way of course, I
need to keep user CB selections on each Tab.

I think I can solve the problem by adding whitespace to the CB datasource
(dB Table/Dataset). Do I need a Leave() event and variable for each CB? Tab
Event? Suggestions welcome. I can''t let this go.

Previous post
http://www.microsoft.com/communities...200&sloc=en-us

推荐答案



" Steve B." <圣**** @ discussions.microsoft.com>在消息中写道

新闻:A3 ********************************** @ microsof t.com ...
Hi,

"Steve B." <St****@discussions.microsoft.com> wrote in message
news:A3**********************************@microsof t.com...
当我的
本地
应用程序启动时,如何将ComboBox文本框保留为数据源项目,即使在用户单击
不同
表格上的标签。

我欢迎任何问题。问题是没有清除CB
文本框中的项目,问题是当用户移动窗体上的选项卡时,我不能将它们保持为空。每个标签都有更多的CB',当然,我需要在每个标签上保留用户CB选项。

我想我可以通过添加空格来解决问题CB数据源
(dB表/数据集)。我是否需要每个CB的Leave()事件和变量?
Tab
事件?建议欢迎。我不能放过这个。

上一篇文章
http://www.microsoft.com /communities...200&sloc=en-us




当切换标签时BindingContextChanged(不必要的)触发,当

BindingContextChanged被触发它还从

CurrencyManager.Position更新ComboBox.SelectedIndex。如果

列表为空,则CurrencyManager.Position只能为-1,否则为0,这就是为什么每次切换选项卡时第一个项目获得
的原因。


默认情况下,Control'隐式使用父表单

中的BindingContext。将表单的BindingContext _explicitly_分配给

ComboBox解决了这个问题。


例如。在表单内:

comboBox1.BindingContext = this.BindingContext;

comboBox1.DataSource = ....;

comboBox1.SelectedIndex = - 1;

comboBox1.SelectedIndex = -1; //两次因为另一个bug

注意:在NET2.0中,两个错误都消失了。


HTH,

问候



When switching tabs BindingContextChanged (unnecessary) fires, when
BindingContextChanged is fired it also updates ComboBox.SelectedIndex from
CurrencyManager.Position. CurrencyManager.Position can only be -1 if the
list is empty, otherwise 0, so that''s why each time the first item gets
selected when switching tabs.

By default, Control''s use the BindingContext from the parent Form
implicitly. Assigning the Form''s BindingContext _explicitly_ to the
ComboBox solves the problem.

eg. inside a Form:
comboBox1.BindingContext = this.BindingContext;
comboBox1.DataSource = .... ;
comboBox1.SelectedIndex = -1;
comboBox1.SelectedIndex = -1; // twice because of another bug
Note: that in NET2.0 both bugs are gone.

HTH,
Greetings


Bart,


谢谢


我认为它必须是这样的(我知道两个-1'),但

我在哪里放你的代码;在Tab事件中?用户选择怎么样。

无论如何,我会尝试实施你的建议,感谢更多信息


史蒂夫


" Bart Mermuys"写道:
Bart,

Thank You

I figured it had to be something like that (I know about the two -1''s), but
where do I put your code; in a Tab event? and what about the user selection.
Anyways, I''ll try to implement your suggestion, any more info is appreciated

Steve

"Bart Mermuys" wrote:


史蒂夫B. <圣**** @ discussions.microsoft.com>在消息中写道
新闻:A3 ********************************** @ microsof t.com。 ..
Hi,

"Steve B." <St****@discussions.microsoft.com> wrote in message
news:A3**********************************@microsof t.com...
当我的
本地
应用程序启动时,如何保持ComboBox文本框中没有数据源项目,并且即使在用户点击
不同之后也保持空白/>表格上的标签。

我欢迎任何问题。问题是没有清除CB
文本框中的项目,问题是当用户移动窗体上的选项卡时,我不能将它们保持为空。每个标签都有更多的CB',当然,我需要在每个标签上保留用户CB选项。

我想我可以通过添加空格来解决问题CB数据源
(dB表/数据集)。我是否需要每个CB的Leave()事件和变量?
Tab
事件?建议欢迎。我不能放过这个。

上一篇文章
http://www.microsoft.com /communities...200&sloc=en-us



当切换标签BindingContextChanged(不必要)时,触发BindingContextChanged时它也会更新ComboBox。来自CurrencyManager.Position的SelectedIndex。如果
列表为空,则CurrencyManager.Position只能为-1,否则为0,这就是为什么每次切换选项卡时第一项被选中的原因。
默认情况下,Control'隐式使用父表单中的BindingContext。将表单的BindingContext _explicitly_分配给
ComboBox解决了这个问题。

例如。在表单内:
comboBox1.BindingContext = this.BindingContext;
comboBox1.DataSource = ....;
comboBox1.SelectedIndex = -1;
comboBox1.SelectedIndex = -1 ; //两次因为另一个bug

注意:在NET2.0中,两个错误都消失了。

HTH,
问候



When switching tabs BindingContextChanged (unnecessary) fires, when
BindingContextChanged is fired it also updates ComboBox.SelectedIndex from
CurrencyManager.Position. CurrencyManager.Position can only be -1 if the
list is empty, otherwise 0, so that''s why each time the first item gets
selected when switching tabs.

By default, Control''s use the BindingContext from the parent Form
implicitly. Assigning the Form''s BindingContext _explicitly_ to the
ComboBox solves the problem.

eg. inside a Form:
comboBox1.BindingContext = this.BindingContext;
comboBox1.DataSource = .... ;
comboBox1.SelectedIndex = -1;
comboBox1.SelectedIndex = -1; // twice because of another bug
Note: that in NET2.0 both bugs are gone.

HTH,
Greetings






" Steve B." <圣**** @ discussions.microsoft.com>在消息中写道

新闻:1B ********************************** @ microsof t.com ...
Hi,

"Steve B." <St****@discussions.microsoft.com> wrote in message
news:1B**********************************@microsof t.com...
Bart,

谢谢

我认为它必须是那样的(我知道这两个 - 1'),

我在哪里放你的代码;在Tab事件中?用户
如何选择。
无论如何,我会尝试实施你的建议,更多信息赞赏


你想要的ComboBox'被清除(即使用户切换标签)

,直到用户选择一些东西,对吗?如果是这样,那么你应该只需要在b / b
中运行前一篇文章中的代码,例如。在表格加载时,不需要

来使用标签事件。


Form_Load:

comboBox1.BindingContext = this.BindingContext; < br $> b $ b ...


hth,

问候语

史蒂夫

Bart Mermuys写道:
Bart,

Thank You

I figured it had to be something like that (I know about the two -1''s),
but
where do I put your code; in a Tab event? and what about the user
selection.
Anyways, I''ll try to implement your suggestion, any more info is
appreciated
You want the ComboBox''s to be cleared (even when the user switches tabs)
until the user selects something, right ? If so then all you should have to
do is run the code in the previous post just once, eg. at Form load, no need
to use tab events.

Form_Load:
comboBox1.BindingContext = this.BindingContext;
...

hth,
Greetings

Steve

"Bart Mermuys" wrote:


史蒂夫B. <圣**** @ discussions.microsoft.com>在消息中写道
新闻:A3 ********************************** @ microsof t.com。 ..
Hi,

"Steve B." <St****@discussions.microsoft.com> wrote in message
news:A3**********************************@microsof t.com...
>当我的
>时,如何保持ComboBox文本框中没有数据源项?当地
>应用程序启动并保持空,即使用户单击
>不同
>表格上的标签。
>
>我欢迎任何问题。问题是没有清除
>中的项目。 CB
>文本框,问题是当用户移动时我不能将它们清空
>周围
>表格上的标签。每个标签都有更多的CB',顺便说一下
>当然,我
>需要在每个标签上保留用户CB选择。
>
>我想我可以通过向CB添加空格来解决问题
>数据源
> (dB表/数据集)。我是否需要每个的Leave()事件和变量
> CB?
>标签
>事件?建议欢迎。我不能放过这个。
>
>上一篇文章
> http://www.microsoft.com/communities...200&sloc=en-us
>
> How can I keep the ComboBox textbox empty of datasource items when my
> local
> application starts AND keep them empty even after the user clicks
> different
> Tabs on the form.
>
> I welcome any questions. The problem isn''t clearing the items from the
> CB
> textbox, the problem is I can''t keep them empty when the user moves
> around
> the Tabs on the form. Each Tab has more CB''s and, by the way of
> course, I
> need to keep user CB selections on each Tab.
>
> I think I can solve the problem by adding whitespace to the CB
> datasource
> (dB Table/Dataset). Do I need a Leave() event and variable for each
> CB?
> Tab
> Event? Suggestions welcome. I can''t let this go.
>
> Previous post
> http://www.microsoft.com/communities...200&sloc=en-us
>



当切换标签BindingContextChanged(不必要)触发时,当激活BindingContextChanged时,它还会从
CurrencyManager.Position更新ComboBox.SelectedIndex
。如果
列表为空,则CurrencyManager.Position只能为-1,否则为0,这就是为什么每次切换选项卡时第一项被选中的原因。
默认情况下,Control'隐式使用父表单中的BindingContext。将表单的BindingContext _explicitly_分配给
ComboBox解决了这个问题。

例如。在表单内:
comboBox1.BindingContext = this.BindingContext;
comboBox1.DataSource = ....;
comboBox1.SelectedIndex = -1;
comboBox1.SelectedIndex = -1 ; //两次因为另一个bug

注意:在NET2.0中,两个错误都消失了。

HTH,
问候



When switching tabs BindingContextChanged (unnecessary) fires, when
BindingContextChanged is fired it also updates ComboBox.SelectedIndex
from
CurrencyManager.Position. CurrencyManager.Position can only be -1 if the
list is empty, otherwise 0, so that''s why each time the first item gets
selected when switching tabs.

By default, Control''s use the BindingContext from the parent Form
implicitly. Assigning the Form''s BindingContext _explicitly_ to the
ComboBox solves the problem.

eg. inside a Form:
comboBox1.BindingContext = this.BindingContext;
comboBox1.DataSource = .... ;
comboBox1.SelectedIndex = -1;
comboBox1.SelectedIndex = -1; // twice because of another bug
Note: that in NET2.0 both bugs are gone.

HTH,
Greetings



这篇关于选项卡和组合框重新发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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