Re: Tabs and ComboBoxes Repost
- From: "Bart Mermuys" <bmermuys.nospam@xxxxxxxxxxx>
- Date: Mon, 21 Nov 2005 00:02:28 +0100
Hi,
"Steve B." <SteveB@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1BCAFA7F-92E7-4114-A469-1BA229AE4275@xxxxxxxxxxxxxxxx
> 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:
>
>> 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
- References:
- Re: Tabs and ComboBoxes Repost
- From: Bart Mermuys
- Re: Tabs and ComboBoxes Repost
- Prev by Date: Re: What Caption for a MessageBox
- Next by Date: Re: How to disconnect all connections of a Database.
- Previous by thread: Re: Tabs and ComboBoxes Repost
- Next by thread: Re: Tabs and ComboBoxes Repost
- Index(es):
Relevant Pages
|