Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Form control event problems

Form control event problems

Scheduled Pinned Locked Moved C#
csshelpquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jefferys
    wrote on last edited by
    #1

    I have a mdi child form that has two combo boxes and a data grid. The combo boxes are used to filter the records in the data grid. The problem I am having is that I load the combo boxes from a dataset in the form load event. I also fill the datagrid from a dataset after loading the combo boxes. It looks to me that the combo box events (selectedvaluechanged) are running before everthing is loaded properly and causes loading errors. Both my combo boxes call a function to reload the datagrid. Am I loading the combo box values in the wrong event? I hope that made sense. Thanks, JefferyS

    L N N J 4 Replies Last reply
    0
    • J Jefferys

      I have a mdi child form that has two combo boxes and a data grid. The combo boxes are used to filter the records in the data grid. The problem I am having is that I load the combo boxes from a dataset in the form load event. I also fill the datagrid from a dataset after loading the combo boxes. It looks to me that the combo box events (selectedvaluechanged) are running before everthing is loaded properly and causes loading errors. Both my combo boxes call a function to reload the datagrid. Am I loading the combo box values in the wrong event? I hope that made sense. Thanks, JefferyS

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Are you setting the selected index for comboboxes? That will cause the event to fire. Try setting the selected index after the datagrid is populated.

      1 Reply Last reply
      0
      • J Jefferys

        I have a mdi child form that has two combo boxes and a data grid. The combo boxes are used to filter the records in the data grid. The problem I am having is that I load the combo boxes from a dataset in the form load event. I also fill the datagrid from a dataset after loading the combo boxes. It looks to me that the combo box events (selectedvaluechanged) are running before everthing is loaded properly and causes loading errors. Both my combo boxes call a function to reload the datagrid. Am I loading the combo box values in the wrong event? I hope that made sense. Thanks, JefferyS

        L Offline
        L Offline
        Looney Tunezez
        wrote on last edited by
        #3

        Maybe in the selectedindex_changed event handler of the comboboxes , try this:

        {
        if( this.combo_Box1.SelectedIndex > 0)
        {
        //Do filtering as required and
        //Reload Grid
        }
        }

        Also, let me know if it actually works ( cross your fingers! ) :~ "Creating tomorrow's legacy systems today..... .... One CRISIS at a time!" -- Unknown "If you build it.... .....BUGS will come!" -JB
        this.Dispose();
        "A Bug is a piece of code that knows whatz its purpose"

        1 Reply Last reply
        0
        • J Jefferys

          I have a mdi child form that has two combo boxes and a data grid. The combo boxes are used to filter the records in the data grid. The problem I am having is that I load the combo boxes from a dataset in the form load event. I also fill the datagrid from a dataset after loading the combo boxes. It looks to me that the combo box events (selectedvaluechanged) are running before everthing is loaded properly and causes loading errors. Both my combo boxes call a function to reload the datagrid. Am I loading the combo box values in the wrong event? I hope that made sense. Thanks, JefferyS

          N Offline
          N Offline
          Nick Parker
          wrote on last edited by
          #4

          A quick solution would be to use a state variable. Set it to true once you have loaded your data and check it within your SelectedValueChanged before you do anything else within it. - Nick Parker
          My Blog | My Articles

          1 Reply Last reply
          0
          • J Jefferys

            I have a mdi child form that has two combo boxes and a data grid. The combo boxes are used to filter the records in the data grid. The problem I am having is that I load the combo boxes from a dataset in the form load event. I also fill the datagrid from a dataset after loading the combo boxes. It looks to me that the combo box events (selectedvaluechanged) are running before everthing is loaded properly and causes loading errors. Both my combo boxes call a function to reload the datagrid. Am I loading the combo box values in the wrong event? I hope that made sense. Thanks, JefferyS

            J Offline
            J Offline
            Jefferys
            wrote on last edited by
            #5

            Thanks for all the suggestions. It seams that when you load the combo box (atleast with a dataset) it fires off the selectedItem and selectedvalue events, and maybe other combo box events. The selectedIndex stayed at 0 all the time so the if(combobox.selectedindex > 0) did work, but sense I was using index 0 for "All" to not filter that category it wasn't going to work for me. So after many cans of A&W Root Beer, I moved the lines that sets the events for both combo boxs under the last item in the form load event which was the loading of the datagrid. It seams to be working perfectly. Thanks again for all the suggestions, JefferyS :-D

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups