Solved

Windows Form Paint Event Not Firing Consistently-VB.Net

Posted on 2009-03-30
4
830 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now