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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

FloatingForm and FormClose event

Thread ID:

Created:

Updated:

Platform:

Replies:

55889 Feb 6,2007 05:41 PM UTC Feb 7,2007 05:48 PM UTC Windows Forms 4
loading
Tags: Tools
Serguei Tarassov
Asked On February 6, 2007 05:41 PM UTC

Hello,

Creating floating form containing our form using recommended method:


formToFloat.TopLevel = false;
formToFloat.ShowInTaskbar = false;
formToFloat.FormBorderStyle = FormBorderStyle.None;
dockingManager1.FloatControl(formToFloat, formToFloat.Bounds);
FloatingForm f = (((DockHost)formToFloat.Parent).ParentForm as FloatingForm));
f.FormClosed += delegate {
MessageBox.Show("FormClosed");
};


If I close floating form (pressing by "x" button of tool window) no FormClosed event is fired.
But it's fires when application exit.

How to handle FormClosed event?

Regards,
Serguei

Murugan [Syncfusion]
Replied On February 6, 2007 06:28 PM UTC

Hi Serguei,

When a FloatingForm is closed, Form's visibility is set to false. The form can be reopened using dockingManager.SetDockVisibility( form , true ). This is the reason for not firing the FormClosed event. When application is closed, Form is disposed. So FormClosed event is fired.

How to handle FormClosed event?

Whenever the control visibility is changed, DockVibilityChanged event is fired. So we could initiate user defined event in this handler to achieve our requirement.

Here is the code snippet:

public delegate void FormClosed(Object sender , Syncfusion.Windows.Forms.Tools.DockVisibilityChangedEventArgs e );
public event FormClosed FormClosedEvent;

private void dockingManager1_DockVisibilityChanged(object sender, Syncfusion.Windows.Forms.Tools.DockVisibilityChangedEventArgs arg)
{
if (!this.dockingManager1.GetDockVisibility(arg.Control) &&
this.dockingManager1.IsFloating(arg.Control))
{
this.FormClosedEvent += new FormClosed(Form1_FormClosedEvent);
this.FormClosedEvent(sender, arg);
}
}

void Form1_FormClosedEvent(object sender, Syncfusion.Windows.Forms.Tools.DockVisibilityChangedEventArgs e)
{
Console.WriteLine(e.Control.Name);
}

Herewith I have also attached the sample. Please have a look at the sample and let me know if it helps.

TDM_55889

Thanks for choosing Syncfusion products.

Regards,
Murugan P.S

Serguei Tarassov
Replied On February 7, 2007 09:45 AM UTC

Murugan,

Thanks for help.
Finally, I use code like this:


if (!dockingManager.GetDockVisibility(arg.Control) && arg.Control is Form)
{
((Form) arg.Control).Close();
}


Regards,
Serguei

Serguei Tarassov
Replied On February 7, 2007 02:27 PM UTC

Murugan,

What about "Load" event ?
It doesn't fired too and i'm afraid that your method is not working in this case: "DockVisibilityChanged" event is not fired when creating new control.

Regards,
Serguei

Murugan [Syncfusion]
Replied On February 7, 2007 05:48 PM UTC

Hi Serguei,

By customizing the DockingManager, we could initiate the FormLoad event when the Form is floated.

Herewith I have attached the sample. Please refer to the sample and let me know if it helps.

TDM_55889

Thanks,
Murugan P.S

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

;