We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Please help me understand a Dispose issue with PopupControl

Thread ID:

Created:

Updated:

Platform:

Replies:

49105 Sep 11,2006 08:56 PM UTC Sep 13,2006 02:02 PM UTC WinForms 4
loading
Tags: Tools
Torque
Asked On September 11, 2006 08:56 PM UTC

Hey guys,

I have an issue with Dispose() and popup controls that I''ve been trying to figure out but havn''t had any luck yet. Hopefully someone here can help. I''m using Syncfusion 2.1.0.9.

I have attached a small sample of a form containing two text boxes and a user control thats made up of a popup container and a popup control. This sample reproduces what I see in my real project, which is too large and complicated to include.

When I leave the user control I check to see if the data is valid in the OnEnter method of control about to be entered. If the user control''s data is not valid I want to focus back on it. Also, when I leave the user control, its popup control is disposed (as in the real app, to preserve resources). The dispose call is made in an async call using BeginInvoke. However, instead of the user control getting the focus back, Dispose calls SelectNextControl and the control after the user control will get the focus. If instead I call dispose syncronously, everything works as expected.

I''m sorry that the above explanation is confusing but if you open and run the attachment it will be much clearer.
- Run the project in the attachment
- Tab into the second control (thats the user control containing the popup)
- change its text so it doesn''t say "textBox1"
- Click the first control (the one you tabbed from)
- When this control is entered it checks the text of the user control. If it isn''t "textBox1" is sets the focus back to the user control.
- Instead of the user control getting the focus, the textbox after it gets the focus.

Comment out line 177 in MyPopupContainer and uncomment line 176 to see the correct behavior.

Please someone help me with this. I''ve been looking for the solution for a while now. I know it has something to do with async vs. sync and have a feeling that it has something to do with Dispose being called during a focus transfer. I''m not sure though if the popup controls do anything special in their Dispose calls.

I just want to understand the behavior I am seeing :)

Any help is greatly appreciated!

Thanks a lot.

-Flack

PopupTest.zip

Anupama Roy [Syncfusion]
Replied On September 12, 2006 07:16 AM UTC

Hi Flack,

Giving an InvokeRequired condition before passing the function DisposePopupCalendar to BeginInvoke will resolve this problem.

Please take a look at the code snippet below:

protected virtual void SetEditMode(bool on_)
{
try
{
if (on_)
{
MakeSurePopupCreated();
}
else if (_calendarPopUp != null)
{
//Using DisposePopupCalendar() directly is ok but using BeginInvoke causes the issue
//DisposePopupCalendar();
if(this.InvokeRequired )
{
BeginInvoke(new MethodInvoker(DisposePopupCalendar));
}
}
_editMode = on_;
}
catch (Exception ex_)
{
MessageBox.Show(ex_.ToString());
}
}


Thanks for your interest in Syncfusion products.

Regards,

Anu.

Administrator [Syncfusion]
Replied On September 12, 2006 01:27 PM UTC

Great. Thanks for the help.

Do you happen to know why I was seeing the focus not go to the user control but go the the next control instead when just using BeginInvoke and why calling it in a syncronous manner or checking if InvokeRequired fixes it?

-Flack

Administrator [Syncfusion]
Replied On September 12, 2006 01:33 PM UTC

Also, using InvokeRequired will cause the DisposePopupCalendar to not be called at all.

How about if I always want it to be Disposed? Is there a way to do it asyncronously and still have the focus correctly set to the user control when setting it from the OnEnter method of another control?

-Flack

Anupama Roy [Syncfusion]
Replied On September 13, 2006 02:02 PM UTC

Hi Flack,

I could see that the method is not getting called when InvokeRequired is used.However,I could not figure out the exact issue behind this.I will investigate deeper and let you know if I can find out something.

Thanks,

Anu.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;