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 Data Binding / December 2004

Tip: Looking for answers? Try searching our database.

Newbie Question: Distinguishing between user click and binding context position change

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
- 13 Dec 2004 21:33 GMT
Hello,

I have a master/detail form using a typed DataSet-a ListBox with the
"master" records and several ComboBoxes with "detail" records.  On the
SelectedIndexChanged handler for the ListBox, it selects the appropriate
detail records in the ComboBoxes.  This, of course, raises a
SelectedIndexChanged for the detail ComboBoxes.

How, then, can I know if the detail ComboBoxes' SelectedIndexChanged events
fired because the user changed them or because the binding context changed
them by changing the master record's position?

Thank you,

Eric
Rajesh Patel - 14 Dec 2004 22:13 GMT
I believe basically you want to perform actions on combobox if user changes
them, not because of bindingcontext change.

There are 2 possible solutions I can think,

1. Use Removehandler and addhandler for all combobox. use removehandler in
listbox before you start poplulate details' combobox and addhandler as soon
as you finished binding combobox with details' records.

2. use boolean variable  blnByBinidingcontext. before you populate values
for comboboxes make this variable true. after binding every combobox make it
again false. This variable should be private at class level. Check this
boolean variable in combobox's selectedindexchanged event. if
blnByBinidingcontext = true then exit procedure.

Regards,
> Hello,
>
[quoted text clipped - 11 lines]
>
> Eric
- 15 Dec 2004 13:47 GMT
I did something quite similar to fix the problem.  It turned out that the
only time there was an overlap with the BindingContext and ComboBoxes'
SelectedIndexChanged events was on form load when the ComboBox was bound to
its data source.

To fix this, I just declared a Boolean var, IsFormLoad.  (Then I of course
set it to True at the beginning and False at the end of the form's load
event.)  Within each combo box's SelectedIndexChanged event, I added code
like the following:

If Not IsFormLoad Then
   ' Code to save back user's changes
   ' to the ListBox's DataView...
End If

Thank you for your reply, Rajesh!

Eric

> I believe basically you want to perform actions on combobox if user changes
> them, not because of bindingcontext change.
[quoted text clipped - 28 lines]
> >
> > Eric

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.