Prevent form opening twice

  • Thread starter Jonathan Crawford
  • Start date
J

Jonathan Crawford

Hi

I have a button in a data grid that opens a frm and
puts some data into it. I wanted to stop the user clicking the
row below and opening another copy of the form.

Dialogue won't work as it won't allow me to put the data in
the rich text box of the newe form

I tried declaring the new form at the top of old form
ie outside the sub that opens it. This works the first time
the form is opened but causes a dispose error the next time the form
is opened.

Not sure what to do
Any advice appreciated

jonathan





--

===============
Jonathan Crawford
01273 440018
07799 068570
fax 01273 380221
(e-mail address removed)
===============
 
M

Maqsood Ahmed

Hello,
It is very simple. Declare a Form object globally (class level). And
put this code when you open the form...

if(form1 == null || form1.IsDisposed)
form1 = new MyForm();

// Populate values in form

HTH, Cheers :)
Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top