0

I have a program in which I create a new form which contains several combo box. When I create the form, I want to fill one of those combo box with a value depending of the time of the day. This so far is working fine.

When I fill the value of in the combo box, the SelectionChanged event is triggered, which is normal. However, I would like to prevent the combo box to do something different if I am still within the form constructor. In this case, I want to show a message box when the selection is changed by a user only.

Something like

If Form.IsFinishedLoading then 'Do something Else 'Do something else End if 

What I usually do in those case is set up a boolean which tells me if I am still in my loading sequence, which is working, but I wonder if there are any other and better way to do this.

Regards

1
  • What about using dispatcher? Commented Jan 8, 2015 at 20:44

1 Answer 1

1

Try using the Dispatcher to fire your code at a later DispatcherPriority than Loaded, such as Input.

 Dispatcher.BeginInvoke(DispatcherPriority.Input, New Action(Sub() dowhat?)) 

Heres a little example thats implemented...

http://sambourton.wordpress.com/2009/07/28/execute-a-method-asynchronously-using-the-dispatcher-queue/

Another great link describing DispatcherPriority enums in ascending order of priority, lowest to highest...

http://sambourton.wordpress.com/2009/07/15/tips-and-tricks-with-the-dispatcher-and-dispatcherpriority-in-wpf/

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.