Link to home
Start Free TrialLog in
Avatar of mpharis
mpharis

asked on

Windows Form Paint Event Not Firing Consistently-VB.Net

I have several variables I am attepting to set when the form reloads/repaints. I am using a Binding Navigator for the first time so that may be part of the issue. When I navigate to another record, the variables which are changed in the Paint event are unchanged. However, if I move my mouse up to the closest control (a textbox) the variable suddently is changed. I've worked through several attempt to nail down the issue and it appears that the Paint event is not firing when i use the BindngNavigator to navigate throught the records. Any advice or input would be appreciated. I have way too much code to include but am attaching a video screen shot of he anomoly. Pay attention to the Currency Manager Position Value in the bottom left of the form.  Also, i have no special "MouseOver" events or anything like that.
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Why dont you use an event of the binding navigator such as CurrentChanged?
Avatar of mpharis
mpharis

ASKER

Because the record may not necessarily be changed. I want to evaluate various situations just prior to the screen redisplaying for user input to determine buttons to hide, buttons to display, button text values to be changed under certain conditions, etc. However, as you can see in the ".avi" sample, the Paint event does not seem to be firing on it's on. Only after I mouse over another control does the event fire and the values in the Paint event get changed. I am open to other methods, but the Paint event has worked fine in the past. (I am still relatively new to Forms development).

I'm looking for a standard method to:  reset values/indicators just after an action is taken on the screen and the reevaluate for certain conditions just prior to the screen becomming availible to the user.
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mpharis

ASKER

Thanks for the input. After having a little more time to investigate and acutally record how the events fire i realized that the Paint event Fire even just for mouse movements over controls. Once I understood that it was clear that was definately the wrong event to use. The problem remained that the Activated and Deactivated events were not firing in response to All Control Actions. Specifically they did not fire when clicking one of the controls on the BindingNavigation. Resolved issue by executing Functions within the Activated and Deactivate Events and manually calling the function within Actions which do not result in the Activated/Deactivate Events.
Thanks for the responses.