|
I have a Treeview control and a Propertygrid control on a form. The tree has more than 100 nodes. On the PropertyValueChanged event of the Propertygrid, I have to perform some long running operations(typically 3 to 5 seconds) and hence I have used Application.DoEvents within this code to keep the UI responsive. My problem is that when I follow these steps: 1. Change some text property on the PropertyGrid 2. Without commiting the change(e.g. by pressing enter, clicking on some other property row, etc) I click on a node in the treeview control. 3. Immediately after clicking, I move the mouse away from the clicked node, but within the tree. This is the event sequence I see: 1. PropertyGrid.PropertyValueChanged event enter 2. Treeview.MouseDown event fired 3. Treeview.MouseUp event fired 4. PropertyGrid.PropertyValueChanged event exit 5. Treeview.MouseDown event fired AGAIN! (Note: no MouseUp is fired) If I remove the Application.DoEvents calls from Propertygrid's PropetyValueChanged event, I see this event sequence: 1. PropertyGrid.PropertyValueChanged event enter 2. PropertyGrid.PropertyValueChanged event exit 3. Treeview.MouseDown event fired 4. Treeview.MouseUp event fired The additional(unwanted) MouseDown event without a matching MouseUp is causing a drag operation to initiate; which of course the user would not want. Is there any way to avoid the additional MouseDown event from firing? Because this event fires after PropertyValueChange exits, setting a flag while my (long running)operation executes doesnot help. Is there any way to keep the UI responsive in this case without the use of Application.DoEvents? I have tried this with VS2005 and VS2008, and got the same results with both. Please Help!
|