Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15504

Form regaining focus

$
0
0
I have an application with a Main form that has a Menu Bar, then 8 Tabs in a Tab Control and 8 forms that appear within the tabs. I have a number of DataGridView controls that display data from an on-line database on the various forms. The DGV's are not "connected" to the database, but updated through queries with datasets.

From the menu on the main form, the user can display modal dialogs that may affect the data that is displayed in one or more of the DGV's on a form in a tab such as adding a member (person) to the database. I have a button on the forms that allows the user to "refresh" or update the DGV after one of these edits or additions to the database is completed, but I would like to simply "detect" when one of these modal dialogs is closed and refresh the currently displayed DGV's on the form in the current tab kind of automatically.

The problem that I seem to run into is that the code to open and close the editing modal dialogs is on the main form, where the code to "refresh" the DGV's is within the forms code that are on the tabs. I would have thought I could use the GotFocus event of the form to detect when the focus left the modal dialog and shifted back to the form in the current tab, but that seems to be unreliable at best. I have tried the forms "Enter" event also, but that too does not seem to fire when simply closing a modal dialog.

When I close one of the said modal dialogs that are displayed over the forms, the the "operational focus" does seem to be put on the form that is currently displayed in the current tab meaning when I click a button it works, it does not take a click to get the focus back to a control on the form. Is there a way to detect when a modal dialog is closed from a VB.Net form or some other way of detecting all of this?

A long question so a big "Thank You!" in advance.

Viewing all articles
Browse latest Browse all 15504

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>