Solved

Windows Form Paint Event Not Firing Consistently-VB.Net

Posted on 2009-03-30
4
844 Views
Last Modified: 2013-11-25
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.
0
Comment
Question by:mpharis
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24033931
Why dont you use an event of the binding navigator such as CurrentChanged?
0
 

Author Comment

by:mpharis
ID: 24034952
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.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 24036882
1) I cant see any avi attached.
2) The Paint event fires every now and then whenever the form is required to repaint itself. This includes when the form is hidden or displayed, when some other form overlaps it, when resizing, when dragging, ... etc. I think it would be a big overhead to do all processing in the paint event. Can you tell us what are the actions which may require you to hide/show form controls.
0
 

Author Comment

by:mpharis
ID: 24065738
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.  
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question