Recurssion + .Net Compact framework -
i working on .net compact framework. per requirement have drop downwards , text box; when user selected value drop downwards selected index changed event fires , value gets updated in textbox. suppose user typed value in textbox need 1 time again set drop downs selected index.
so above scenario went recursion.
please help me out resolve this.
two simple solutions come mind:
a) flag utilize simple variable _preventrecursion
indicate update should take place, illustration this:
private volatile bool _preventrecursion; public void textbox_textchanged(...) { if (!_preventrecursion) { _preventrecursion = true; seek { // stuff update combo box. } { _preventrecursion = false; } } }
add same code event handler combo box.
b) manually attach event handlers if manually attach event handlers in code, command when events available:
public void textbox_textchanged(...) { combobox1.selectedindexchanged -= selectedindexchangedeventhandler; seek { // stuff update combo box } { combobox1.selectedindexchanged += selectedindexchangedeventhandler; } }
selectedindexchangedeventhandler
proper delegate.
.net
No comments:
Post a Comment