Form control event problems
-
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
-
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
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.
-
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
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 ofcode
that knows whatz its purpose" -
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
A quick solution would be to use a state variable. Set it to
true
once you have loaded your data and check it within yourSelectedValueChanged
before you do anything else within it. - Nick Parker
My Blog | My Articles -
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
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