Form.show + Single instance.
I have two forms ,
say FormA and FormB
In FormA, a Button Click i wrote FormB.Show.
When i click again the button its creating another instance of FormB.
i want to make FormB as single instane, if again the button event raised i need to focus the FormB rather creating another instance.
Re: Form.show + Single instance.
If all you did was FormB.Show then it's not creating another instance, so either you are incorrect or you aren't telling us everything. The code, as you have shown it, is using the default instance. there's only one default instance so you could only be showing one form. If there are multiple instances then you must be creating multiple instances, something like this:
vb.net Code:
Dim f As New FormB
f.Show()
As much as I generally don't like default instances, the singleton-like behaviour that they provide is handy in certain situations and, as that's the behaviour you want, this is a situation where using a default instance is advisable. Assuming that your class is named FormB, this code will display an instance if one isn;t already displayed and focus it if there is:
vb.net Code:
FormB.Show()
FormB.Activate()
Re: Form.show + Single instance.
Quote:
Originally Posted by
vijy
I have two forms ,
say FormA and FormB
In FormA, a Button Click i wrote FormB.Show.
When i click again the button its creating another instance of FormB.
i want to make FormB as single instane, if again the button event raised i need to focus the FormB rather creating another instance.
have you made the objects of the forms?