Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / September 2004

Tip: Looking for answers? Try searching our database.

SelectedIndexChanged event in comboA causes same event to fire in comboB

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
moondaddy - 24 Sep 2004 23:55 GMT
I have a vb.net 1.1 winforms app and have several combo boxes on a form  2
combos have the same data and are populated from the same data table using
the bind method. One is the ShipToAddress and the other is the
BillToAddress.  when the user selects an address in the shipto combo, after
its SelectedIndexChanged event fires, the SelectedIndexChanged event fires
in the BillTo combo which, of course, is causing big problems.

Why is this?  is it because they are bound to the same data table?  Is it a
bug in vs 1.1? Can anyone recommend a fix or work around for this?

Thanks.

Signature

moondaddy@nospam.com

Mark Mischke - 25 Sep 2004 01:39 GMT
My first guess would be that it has something to do with both controls
sharing a common DataSource reference.

Try cloning the DataTable, so each ComboBox has equivalent, but
physically different, bound DataTables:

For instance, if your DataTable is called dt:

ComboA.DataSource = dt.Clone()
ComboB.DataSource = dt.Clone()

All of this is based upon the assumption (which may be incorrect) that
bound data container events may play a role in the triggerring of
certain control events.  In general, it's usually safer to avoid
letting multiple objects share common references, unless you have a
specific reason to do so.

I hope this is useful...

>I have a vb.net 1.1 winforms app and have several combo boxes on a form  2
>combos have the same data and are populated from the same data table using
[quoted text clipped - 7 lines]
>
>Thanks.
moondaddy - 25 Sep 2004 06:11 GMT
Yes, this fixed the problem.  actually just before I got your msg I tried
something similar such as creating a new dataset and merging the table into
it.  I think cloning may be better.  anyway, this worked, but I hope this
can get fixed in the future because if I need to update the dataset client
side and a bunch of controls are using the dataset as a datasource, then
every time the dataset gets updated, all the controls would have to be
rebound again which defeats some of the benefit of ado dataset and binding
them to controls where the data in the control stays in sync with the
dataset.

Thanks for the reply.

Signature

moondaddy@nospam.com

> My first guess would be that it has something to do with both controls
> sharing a common DataSource reference.
[quoted text clipped - 26 lines]
> >
> >Thanks.
Stephany Young - 26 Sep 2004 09:23 GMT
I think that cloning datatables or creating new datatables is overkill.

This is what dataviw objects are designed for.

If you bind multiple controls to a databale then then when the current
pointer in the table moves then all the bound controls will reflect that
movement.

If you have a dataview for each control then the current pointer moves in
the dataview and not the datatable, thus making each control independent but
still getting it's list from the same physical data but via a different
logical path.

> Yes, this fixed the problem.  actually just before I got your msg I tried
> something similar such as creating a new dataset and merging the table into
[quoted text clipped - 43 lines]
> > >
> > >Thanks.
Mark Mischke - 27 Sep 2004 16:04 GMT
Ah, good point.  DataViews are definitely a better approach...

>I think that cloning datatables or creating new datatables is overkill.
>
[quoted text clipped - 58 lines]
>> > >
>> > >Thanks.
moondaddy - 29 Sep 2004 04:04 GMT
Thanks!  That's really good to know.  I thought I was saving steps by just
binding straight to the table, but I know better now.

Signature

moondaddy@nospam.com

> I think that cloning datatables or creating new datatables is overkill.
>
[quoted text clipped - 58 lines]
> > > >
> > > >Thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.