Search code examples
c#winformsmessagebox

MessageBox is hidden when select different tab page


I am doing a check-in check-out system for equipment and chemical item. Firstly, I design check-in/checkout only for equipment. Everything works fine. When I click checkout button, a message box will pop out showing the item is checked out.

Then I add in chemical, which the equipment list and chemical list display on datagridview in different tab page (Using tab control). 1) When I select the equipment list and click the checkout button, a message box will pop out. 2) when I select the chemical list and click the checkout button, a message box will not pop out and the current window is unclickable. Until I use other windows to cover the application and click the application again, then I can see the pop-out message box. After I close the pop-out message box, all the function works well.

The code for message box pop out:

 MessageBox.Show("Item successfully checked out.", "Success");
 DialogResult = DialogResult.OK;
 Close();

EDIT

I found out that the datagridview for the chemical list is somehow refreshing all the data inside although no code is called to refresh the dataview.


Solution

  • Some other events are running cause the window did not pop out immediately. The problem I am facing is rowprepaint events. It causes the events always running and the window still focuses and activated. That why the new window pop out did not show up.