Re: Tabs and ComboBoxes Repost
- From: "Bart Mermuys" <bmermuys.nospam@xxxxxxxxxxx>
- Date: Sat, 19 Nov 2005 23:33:45 +0100
Hi,
"Steve B." <SteveB@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A38F1CE3-0110-4676-94DA-0F29EC7A9648@xxxxxxxxxxxxxxxx
> 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/newsgroups/en-us/default.aspx?dg=microsoft.public.dotnet.languages.csharp&mid=f105eb74-be55-441d-bfe4-e1376e9f7200&sloc=en-us
>
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
.
- Follow-Ups:
- Re: Tabs and ComboBoxes Repost
- From: Steve B.
- Re: Tabs and ComboBoxes Repost
- Prev by Date: Rapid Open/Close of a Windows Form
- Next by Date: Re: Autoselect text when tabbing into a textbox
- Previous by thread: Rapid Open/Close of a Windows Form
- Next by thread: Re: Tabs and ComboBoxes Repost
- Index(es):
Relevant Pages
|