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 / Languages / C# / December 2007

Tip: Looking for answers? Try searching our database.

binding source poisiton event executed too many times

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GS - 21 Dec 2007 09:32 GMT
the windows form application works but the eventhandler for binding source
postionChanged got executed too many times: 12 times from saveitemclicked
for the data navigator
many time from additem

here is the code snippet:

I have a datagridview and a detailView

in form load:
           Binding regexoptionBinding = regexOptionListBox.DataBindings[0];
           regexoptionBinding.Format += new ConvertEventHandler
               (this.setRegexoptionsListBoxOnPosnChgd);

// ....

       private void setRegexoptionsListBoxOnPosnChgd(object sender,
ConvertEventArgs cevent)
       {
           addMsg("@@debug in regexBindingSource_positionChanged1 " +
cevent.Value);
           if ((cevent.Value == DBNull.Value))
           {
               cevent.Value = "0";
           }
           else
           {

setRegexoptionsListBox(cevent.Value.ToString());               }
       }

       private void setRegexoptionsListBox(string sValue)
       {
           // set regexOptions listbox
           if (sValue == "") return;
           int iro;

           try
           {
               iro = int.Parse(sValue);
           } catch (Exception eip){
               setStatus("Warning: invalid Value for regexOptions from
database=" + sValue + CScrlf + eip.Message);
               regexOptionListBox.SelectedItem = sValue;
               return;
           }

           regexOptionListBox.SelectedItem =
               regexOptionListBox.FindStringExact(sValue);
           addMsg("@@debug setRegexoptionsListBox  - "
               +"RegexOptionListBox set from db "+sValue);
       }

the problem is when I click on the save button int eh datanavigator after
changing the RegexOptionListBox to a new value, I will get the event
setRegexoptionsListBox executed 12 times..

I tried changing the code
   bool bIgnorePosnChg = false;
           private void regexBindingNavigatorSaveItem_Click(object sender,
EventArgs e)
       {
           bIgnorePosnChg = true;
           this.Validate();
           this.regexBindingSource.EndEdit();
           this.tableAdapterManager.UpdateAll(this.ieStringTmpDataSet);
           bIgnorePosnChg = false;
       }

and in the beginning of
        private void setRegexoptionsListBox(string sValue)
       {
                       if (sValue == "") return;
           int iro;

           try
           {
               iro = int.Parse(sValue);
           } catch (Exception eip){
               setStatus("Warning: invalid Value for regexOptions from
database=" + sValue + CScrlf + eip.Message);
               regexOptionListBox.SelectedItem = sValue;
               return;
           }

           regexOptionListBox.SelectedItem =
               regexOptionListBox.FindStringExact(sValue);
           addMsg("@@debug in setRegexoptionsListBox..selecteditem=" +
                regexOptionListBox.SelectedItem + ", selIDX=" +
                   regexOptionListBox.SelectedIndex + ". value=" +
                   regexOptionListBox.SelectedValue);
}

and I don't get the first record's RegexoptionsListBox properly selected
that leads to zapping the value to zero!

I am confused. I tried for house looking and different combination and I
still fail to solve the two problem:
GS - 24 Dec 2007 08:07 GMT
not sure what went wrong, I deleted  a  bunch of statements, redesign to
rely on textbox bound to regexoption, for input flue and have the listbox
for regexoption unbound and use formatter that way.  the problem of improper
value for first record no longer exist
> the windows form application works but the eventhandler for binding source
> postionChanged got executed too many times: 12 times from saveitemclicked
[quoted text clipped - 94 lines]
> I am confused. I tried for house looking and different combination and I
> still fail to solve the two problem:

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.