PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework problem reusing Dialog Form

Reply

problem reusing Dialog Form

 
Thread Tools Rate Thread
Old 05-08-2003, 01:24 AM   #1
djohnson
Guest
 
Posts: n/a
Default problem reusing Dialog Form


ok, I have a form that I wish to use as a Dialog Form to edit item details,
when I use the form more than once it becomes unresponsive to setting the
dialogresult.

this app is based on the TaskVision architecture:

in a global class I have a static dialog form item...
declared as such:
************************************************** This is the declaration
in the global class

static ItemDetailForm m_ItemDetailForm;

I also have static methods called:

************************************************** This method is called to
load the form from the splash page

// LOAD ItemDetailForm into Global variable

static public void LoadItemDetailForm()

{

if (m_ItemDetailForm == null)

m_ItemDetailForm = new ItemDetailForm();

}

************************************************** When a button is clicked
on the main form this method is called to return the form object

// RETURN the ItemDetailForm

static public ItemDetailForm GetItemDetailForm()

{

if (m_ItemDetailForm== null)

m_ItemDetailForm= new ItemDetailForm();

return m_ItemDetailForm;

}

************************************************** This is the main form
button code

ItemDetailForm fdf = Global.GetItemDetailForm();

fdf.DataChanged +=new EventHandler(detailform_DataChanged);

fdf.FoodID = FoodID;

fdf.ShowDialog();

************************************************** the first time the above
code is called, everything works fine, the dialog is displayed, I make
modifications to the data and click an update button that does the following
on the dialog form.

DialogResult = DialogResult.OK;

************************************************** this line closes the form
and returns to the calling form correctly.as expected.

if I try to call the dialog form again, it is displayed properly, but the
following line has no impact...

DialogResult = DialogResult.OK;

after this line of code the form acts as though nothing was clicked, in fact
setting dialogresult.cancel has no response as well.

one thing I have tried it setting the form.dialogresult=dialogresult.none
prior to opening the form, with no luck.



I am sort of new to C#, so is there something obvious Im overlooking about
using modaldialogs?

Apreciate any/all help about this matter anyone can provide.

Thanks,

David Johnson


  Reply With Quote
Old 20-08-2003, 12:34 AM   #2
Xin Yan
Guest
 
Posts: n/a
Default RE: problem reusing Dialog Form

Hi, David
It's hard to see what's wrong from your code. Here is some suggestions:
1. Check your DataChanged event handler implementation. In the button code
you subscribe the DataChanged event. Did you un-subscribe the event after
the form is being used?
2. Start with simple code. Comment out your code and see where it starts to
get broken.
3. When it hangs - can you get a stack trace?
Hope this helps
Thanks
Xin

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off