Reputation: 230
I have created a list form that gets attached to a main form in VB.NET. This all works fine except that when the main form gets activated, I need the list to be brought to the front as well. I have put in a simple IF function to do this but when I added these lines of code, the main form, as well as the list form now do not get brought to the front until you let go of the mouse button. Obviously this means that if you drag the form, it stays at the back until you let go of the mouse button.
The code that I added is below:
If CRL.Visible = True Then
CRL.BringToFront()
End If
CRL is the list form.
If I comment out this code again, the main form get brought to the front while dragging but obviously the list form does not. The main form as well as the list form are MDI children.
Upvotes: 2
Views: 170
Reputation: 4348
You trick it by topmost property:
If CRL.Visible = True Then
CRL.BringToFront()
CRL.TopMost = True
Application.DoEvents
CRL.TopMost = False
End If
Upvotes: 2