By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,574 Members | 2,960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,574 IT Pros & Developers. It's quick & easy.

re-parenting a user control causes tooltips to remember original form

P: n/a
I have an issue where I have a user control that is launched into a
floating form. At some point later, I allow the user to "unfloat" the
user control by reparenting it on a split container in another form.
Problem is if I wake a tooltip when the window is floated, and then try
the same thing when it is reparented, the app crashes with " Cannot
access a disposed object.Object name: 'Form'.

Presumably, this is a result of the tooltips still keeping a reference
to the original form (container).

I know that tooltips have to be found using reflection and the controls
IContainer, but I am not sure how to go about this.

Is there a way to "reorient" all the tooltips to the new container?

Jan 3 '07 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Hi,

To "unhook" a tooltip from a control call:

tooltip.SetToolTip(control, string.Empty);

To add it back:

tooltip.SetToolTip(control, "Your tooltip text");
You have to remove tooltip before you destroy the form and add it back
when you create it again.

Regards,
Valentin Ivanov

On Jan 3, 9:08 am, timn...@gmail.com wrote:
I have an issue where I have a user control that is launched into a
floating form. At some point later, I allow the user to "unfloat" the
user control by reparenting it on a split container in another form.
Problem is if I wake a tooltip when the window is floated, and then try
the same thing when it is reparented, the app crashes with " Cannot
access a disposed object.Object name: 'Form'.

Presumably, this is a result of the tooltips still keeping a reference
to the original form (container).

I know that tooltips have to be found using reflection and the controls
IContainer, but I am not sure how to go about this.

Is there a way to "reorient" all the tooltips to the new container?
Jan 3 '07 #2

P: n/a
Nope. I don't have a handle to the tooltip. I have a handle to the
form. I need to iterate the controls and their components and find
(using reflection since components are a private variable) the tool
tips.
On Jan 3, 9:38 am, "Architect" <Valen.Iva...@gmail.comwrote:
Hi,

To "unhook" a tooltip from a control call:

tooltip.SetToolTip(control, string.Empty);

To add it back:

tooltip.SetToolTip(control, "Your tooltip text");

You have to remove tooltip before you destroy the form and add it back
when you create it again.

Regards,
Valentin Ivanov

On Jan 3, 9:08 am, timn...@gmail.com wrote:
I have an issue where I have a user control that is launched into a
floating form. At some point later, I allow the user to "unfloat" the
user control by reparenting it on a split container in another form.
Problem is if I wake a tooltip when the window is floated, and then try
the same thing when it is reparented, the app crashes with " Cannot
access a disposed object.Object name: 'Form'.
Presumably, this is a result of the tooltips still keeping a reference
to the original form (container).
I know that tooltips have to be found using reflection and the controls
IContainer, but I am not sure how to go about this.
Is there a way to "reorient" all the tooltips to the new container?
Jan 3 '07 #3

P: n/a
BTW... the ToolTip is on a ToolStripItem and it seems to hold a
reference to the old form.

ti*****@gmail.com wrote:
Nope. I don't have a handle to the tooltip. I have a handle to the
form. I need to iterate the controls and their components and find
(using reflection since components are a private variable) the tool
tips.
On Jan 3, 9:38 am, "Architect" <Valen.Iva...@gmail.comwrote:
Hi,

To "unhook" a tooltip from a control call:

tooltip.SetToolTip(control, string.Empty);

To add it back:

tooltip.SetToolTip(control, "Your tooltip text");

You have to remove tooltip before you destroy the form and add it back
when you create it again.

Regards,
Valentin Ivanov

On Jan 3, 9:08 am, timn...@gmail.com wrote:
I have an issue where I have a user control that is launched into a
floating form. At some point later, I allow the user to "unfloat" the
user control by reparenting it on a split container in another form.
Problem is if I wake a tooltip when the window is floated, and then try
the same thing when it is reparented, the app crashes with " Cannot
access a disposed object.Object name: 'Form'.
Presumably, this is a result of the tooltips still keeping a reference
to the original form (container).
I know that tooltips have to be found using reflection and the controls
IContainer, but I am not sure how to go about this.
Is there a way to "reorient" all the tooltips to the new container?
Jan 3 '07 #4

P: n/a
Smallest example of issue below. Click the "open" button, hover over
the menu item to see the tool tip, click the "copy" button... now hover
over the menu item on the new form.... boom exception

--------- CUT HERE ----

using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace ToolTipIssue
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new InitialForm());
}
}
public class InitialForm : Form
{
public InitialForm()
{
Button b = new Button();
b.Text = "Open Form";
Controls.Add(b);
b.Click += new EventHandler(b_Click);
}

void b_Click(object sender, EventArgs e)
{
MyForm f = new MyForm();
f.Show();
}
}
public class MyForm : Form
{
Panel p;
public MyForm()
{
p = new Panel();
ToolStrip t = new ToolStrip();
ToolStripButton b = new ToolStripButton();
b.Text = "Hello";
b.ToolTipText = "Hello ToolTip";
t.Items.Add(b);
p.BorderStyle = BorderStyle.Fixed3D;
p.Controls.Add(t);
Controls.Add(p);

Button bt = new Button();
bt.Text = "Copy";
bt.Click += new EventHandler(b_Click);
bt.Location = new System.Drawing.Point(0, 100);
Controls.Add(bt);
}

void b_Click(object sender, EventArgs e)
{
Form f = new Form();
f.Controls.Add(p);
Close();
f.Show();
}
}
}

On Jan 3, 11:31 am, timn...@gmail.com wrote:
BTW... the ToolTip is on a ToolStripItem and it seems to hold a
reference to the old form.

timn...@gmail.com wrote:
Nope. I don't have a handle to the tooltip. I have a handle to the
form. I need to iterate the controls and their components and find
(using reflection since components are a private variable) the tool
tips.
On Jan 3, 9:38 am, "Architect" <Valen.Iva...@gmail.comwrote:
Hi,
To "unhook" a tooltip from a control call:
tooltip.SetToolTip(control, string.Empty);
To add it back:
tooltip.SetToolTip(control, "Your tooltip text");
You have to remove tooltip before you destroy the form and add it back
when you create it again.
Regards,
Valentin Ivanov
On Jan 3, 9:08 am, timn...@gmail.com wrote:
I have an issue where I have a user control that is launched into a
floating form. At some point later, I allow the user to "unfloat" the
user control by reparenting it on a split container in another form.
Problem is if I wake a tooltip when the window is floated, and then try
the same thing when it is reparented, the app crashes with " Cannot
access a disposed object.Object name: 'Form'.
Presumably, this is a result of the tooltips still keeping a reference
to the original form (container).
I know that tooltips have to be found using reflection and the controls
IContainer, but I am not sure how to go about this.
Is there a way to "reorient" all the tooltips to the new container?
Jan 3 '07 #5

P: n/a
Hi,

The example doesn't show the problem because you are closing main form
before showing the second form which will lead to application end.
But even in this example tooltip is not tied to a form so it should be fine
to move panel around.

You can try it by commenting "Close();" call.

Regards,
Valentin Ivanov.

<ti*****@gmail.comwrote in message
news:11**********************@a3g2000cwd.googlegro ups.com...
Smallest example of issue below. Click the "open" button, hover over
the menu item to see the tool tip, click the "copy" button... now hover
over the menu item on the new form.... boom exception

--------- CUT HERE ----

using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace ToolTipIssue
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new InitialForm());
}
}
public class InitialForm : Form
{
public InitialForm()
{
Button b = new Button();
b.Text = "Open Form";
Controls.Add(b);
b.Click += new EventHandler(b_Click);
}

void b_Click(object sender, EventArgs e)
{
MyForm f = new MyForm();
f.Show();
}
}
public class MyForm : Form
{
Panel p;
public MyForm()
{
p = new Panel();
ToolStrip t = new ToolStrip();
ToolStripButton b = new ToolStripButton();
b.Text = "Hello";
b.ToolTipText = "Hello ToolTip";
t.Items.Add(b);
p.BorderStyle = BorderStyle.Fixed3D;
p.Controls.Add(t);
Controls.Add(p);

Button bt = new Button();
bt.Text = "Copy";
bt.Click += new EventHandler(b_Click);
bt.Location = new System.Drawing.Point(0, 100);
Controls.Add(bt);
}

void b_Click(object sender, EventArgs e)
{
Form f = new Form();
f.Controls.Add(p);
Close();
f.Show();
}
}
}

On Jan 3, 11:31 am, timn...@gmail.com wrote:
>BTW... the ToolTip is on a ToolStripItem and it seems to hold a
reference to the old form.

timn...@gmail.com wrote:
Nope. I don't have a handle to the tooltip. I have a handle to the
form. I need to iterate the controls and their components and find
(using reflection since components are a private variable) the tool
tips.
On Jan 3, 9:38 am, "Architect" <Valen.Iva...@gmail.comwrote:
Hi,
To "unhook" a tooltip from a control call:
tooltip.SetToolTip(control, string.Empty);
To add it back:
tooltip.SetToolTip(control, "Your tooltip text");
You have to remove tooltip before you destroy the form and add it
back
when you create it again.
Regards,
Valentin Ivanov
On Jan 3, 9:08 am, timn...@gmail.com wrote:
I have an issue where I have a user control that is launched into a
floating form. At some point later, I allow the user to "unfloat"
the
user control by reparenting it on a split container in another
form.
Problem is if I wake a tooltip when the window is floated, and then
try
the same thing when it is reparented, the app crashes with " Cannot
access a disposed object.Object name: 'Form'.
Presumably, this is a result of the tooltips still keeping a
reference
to the original form (container).
I know that tooltips have to be found using reflection and the
controls
IContainer, but I am not sure how to go about this.
Is there a way to "reorient" all the tooltips to the new container?
Jan 3 '07 #6

P: n/a
I beg to differ. The start up form is "InitialForm" it never gets
closed. I ran this and it reproduces the error.

On Jan 3, 2:45 pm, "Architect" <valen.iva...@gmail.comwrote:
Hi,

The example doesn't show the problem because you are closing main form
before showing the second form which will lead to application end.
But even in this example tooltip is not tied to a form so it should be fine
to move panel around.

You can try it by commenting "Close();" call.

Regards,
Valentin Ivanov.

<timn...@gmail.comwrote in messagenews:11**********************@a3g2000cwd.go oglegroups.com...
Smallest example of issue below. Click the "open" button, hover over
the menu item to see the tool tip, click the "copy" button... now hover
over the menu item on the new form.... boom exception
--------- CUT HERE ----
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace ToolTipIssue
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new InitialForm());
}
}
public class InitialForm : Form
{
public InitialForm()
{
Button b = new Button();
b.Text = "Open Form";
Controls.Add(b);
b.Click += new EventHandler(b_Click);
}
void b_Click(object sender, EventArgs e)
{
MyForm f = new MyForm();
f.Show();
}
}
public class MyForm : Form
{
Panel p;
public MyForm()
{
p = new Panel();
ToolStrip t = new ToolStrip();
ToolStripButton b = new ToolStripButton();
b.Text = "Hello";
b.ToolTipText = "Hello ToolTip";
t.Items.Add(b);
p.BorderStyle = BorderStyle.Fixed3D;
p.Controls.Add(t);
Controls.Add(p);
Button bt = new Button();
bt.Text = "Copy";
bt.Click += new EventHandler(b_Click);
bt.Location = new System.Drawing.Point(0, 100);
Controls.Add(bt);
}
void b_Click(object sender, EventArgs e)
{
Form f = new Form();
f.Controls.Add(p);
Close();
f.Show();
}
}
}
On Jan 3, 11:31 am, timn...@gmail.com wrote:
BTW... the ToolTip is on a ToolStripItem and it seems to hold a
reference to the old form.
timn...@gmail.com wrote:
Nope. I don't have a handle to the tooltip. I have a handle to the
form. I need to iterate the controls and their components and find
(using reflection since components are a private variable) the tool
tips.
On Jan 3, 9:38 am, "Architect" <Valen.Iva...@gmail.comwrote:
Hi,
To "unhook" a tooltip from a control call:
tooltip.SetToolTip(control, string.Empty);
To add it back:
tooltip.SetToolTip(control, "Your tooltip text");
You have to remove tooltip before you destroy the form and add it
back
when you create it again.
Regards,
Valentin Ivanov
On Jan 3, 9:08 am, timn...@gmail.com wrote:
I have an issue where I have a user control that is launched into a
floating form. At some point later, I allow the user to "unfloat"
the
user control by reparenting it on a split container in another
form.
Problem is if I wake a tooltip when the window is floated, and then
try
the same thing when it is reparented, the app crashes with " Cannot
access a disposed object.Object name: 'Form'.
Presumably, this is a result of the tooltips still keeping a
reference
to the original form (container).
I know that tooltips have to be found using reflection and the
controls
IContainer, but I am not sure how to go about this.
Is there a way to "reorient" all the tooltips to the new container?
Jan 4 '07 #7

P: n/a
Yes, you right. I was modifying my existing sandbox solution and used
"MyForm" in the Application.Run call.
Anyways I was able to reproduce the issue. In my case it gives me:

FatalExecutionEngineError was detected
Message: The runtime has encountered a fatal error. The address of the error
was at 0x7f4bb7a3, on thread 0x1f94. The error code is 0xc0000005. This
error may be a bug in the CLR or in the unsafe or non-verifiable portions of
user code. Common sources of this bug include user marshaling errors for
COM-interop or PInvoke, which may corrupt the stack.
I would say that it is a real bug in the CLR. I would report it to
Microsoft.
Meanwhile I'll try to help you and look if there is a workaround.

Regards,
Valentin Ivanov.
<ti*****@gmail.comwrote in message
news:11**********************@42g2000cwt.googlegro ups.com...
>I beg to differ. The start up form is "InitialForm" it never gets
closed. I ran this and it reproduces the error.

On Jan 3, 2:45 pm, "Architect" <valen.iva...@gmail.comwrote:
>Hi,

The example doesn't show the problem because you are closing main form
before showing the second form which will lead to application end.
But even in this example tooltip is not tied to a form so it should be
fine
to move panel around.

You can try it by commenting "Close();" call.

Regards,
Valentin Ivanov.

<timn...@gmail.comwrote in
messagenews:11**********************@a3g2000cwd.g ooglegroups.com...
Smallest example of issue below. Click the "open" button, hover over
the menu item to see the tool tip, click the "copy" button... now hover
over the menu item on the new form.... boom exception
--------- CUT HERE ----
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace ToolTipIssue
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new InitialForm());
}
}
public class InitialForm : Form
{
public InitialForm()
{
Button b = new Button();
b.Text = "Open Form";
Controls.Add(b);
b.Click += new EventHandler(b_Click);
}
void b_Click(object sender, EventArgs e)
{
MyForm f = new MyForm();
f.Show();
}
}
public class MyForm : Form
{
Panel p;
public MyForm()
{
p = new Panel();
ToolStrip t = new ToolStrip();
ToolStripButton b = new ToolStripButton();
b.Text = "Hello";
b.ToolTipText = "Hello ToolTip";
t.Items.Add(b);
p.BorderStyle = BorderStyle.Fixed3D;
p.Controls.Add(t);
Controls.Add(p);
Button bt = new Button();
bt.Text = "Copy";
bt.Click += new EventHandler(b_Click);
bt.Location = new System.Drawing.Point(0, 100);
Controls.Add(bt);
}
void b_Click(object sender, EventArgs e)
{
Form f = new Form();
f.Controls.Add(p);
Close();
f.Show();
}
}
}
On Jan 3, 11:31 am, timn...@gmail.com wrote:
BTW... the ToolTip is on a ToolStripItem and it seems to hold a
reference to the old form.
>timn...@gmail.com wrote:
Nope. I don't have a handle to the tooltip. I have a handle to the
form. I need to iterate the controls and their components and find
(using reflection since components are a private variable) the tool
tips.
On Jan 3, 9:38 am, "Architect" <Valen.Iva...@gmail.comwrote:
Hi,
To "unhook" a tooltip from a control call:
tooltip.SetToolTip(control, string.Empty);
To add it back:
tooltip.SetToolTip(control, "Your tooltip text");
You have to remove tooltip before you destroy the form and add it
back
when you create it again.
Regards,
Valentin Ivanov
On Jan 3, 9:08 am, timn...@gmail.com wrote:
I have an issue where I have a user control that is launched
into a
floating form. At some point later, I allow the user to
"unfloat"
the
user control by reparenting it on a split container in another
form.
Problem is if I wake a tooltip when the window is floated, and
then
try
the same thing when it is reparented, the app crashes with "
Cannot
access a disposed object.Object name: 'Form'.
Presumably, this is a result of the tooltips still keeping a
reference
to the original form (container).
I know that tooltips have to be found using reflection and the
controls
IContainer, but I am not sure how to go about this.
Is there a way to "reorient" all the tooltips to the new
container?
Jan 5 '07 #8

P: n/a
Ok,

The problem lies in the ToolStrip control (too bad we don't have access to
the tooltip).
The only way to solve it is to recreate toolstrip.

Add a method to you user control which will
1. remove existing toolstrip
2. create new toolstrip
3. readd all items to the new toolstrip
4. add new toolstrip

Call that method each time you transfer your user control.

Regards,
Valentin Ivanov.

"Architect" <va**********@gmail.comwrote in message
news:F9**********************************@microsof t.com...
Yes, you right. I was modifying my existing sandbox solution and used
"MyForm" in the Application.Run call.
Anyways I was able to reproduce the issue. In my case it gives me:

FatalExecutionEngineError was detected
Message: The runtime has encountered a fatal error. The address of the
error was at 0x7f4bb7a3, on thread 0x1f94. The error code is 0xc0000005.
This error may be a bug in the CLR or in the unsafe or non-verifiable
portions of user code. Common sources of this bug include user marshaling
errors for COM-interop or PInvoke, which may corrupt the stack.
I would say that it is a real bug in the CLR. I would report it to
Microsoft.
Meanwhile I'll try to help you and look if there is a workaround.

Regards,
Valentin Ivanov.
<ti*****@gmail.comwrote in message
news:11**********************@42g2000cwt.googlegro ups.com...
>>I beg to differ. The start up form is "InitialForm" it never gets
closed. I ran this and it reproduces the error.

On Jan 3, 2:45 pm, "Architect" <valen.iva...@gmail.comwrote:
>>Hi,

The example doesn't show the problem because you are closing main form
before showing the second form which will lead to application end.
But even in this example tooltip is not tied to a form so it should be
fine
to move panel around.

You can try it by commenting "Close();" call.

Regards,
Valentin Ivanov.

<timn...@gmail.comwrote in
messagenews:11**********************@a3g2000cwd. googlegroups.com...

Smallest example of issue below. Click the "open" button, hover over
the menu item to see the tool tip, click the "copy" button... now
hover
over the menu item on the new form.... boom exception

--------- CUT HERE ----

using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace ToolTipIssue
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new InitialForm());
}
}
public class InitialForm : Form
{
public InitialForm()
{
Button b = new Button();
b.Text = "Open Form";
Controls.Add(b);
b.Click += new EventHandler(b_Click);
}

void b_Click(object sender, EventArgs e)
{
MyForm f = new MyForm();
f.Show();
}
}
public class MyForm : Form
{
Panel p;
public MyForm()
{
p = new Panel();
ToolStrip t = new ToolStrip();
ToolStripButton b = new ToolStripButton();
b.Text = "Hello";
b.ToolTipText = "Hello ToolTip";
t.Items.Add(b);
p.BorderStyle = BorderStyle.Fixed3D;
p.Controls.Add(t);
Controls.Add(p);

Button bt = new Button();
bt.Text = "Copy";
bt.Click += new EventHandler(b_Click);
bt.Location = new System.Drawing.Point(0, 100);
Controls.Add(bt);
}

void b_Click(object sender, EventArgs e)
{
Form f = new Form();
f.Controls.Add(p);
Close();
f.Show();
}
}
}

On Jan 3, 11:31 am, timn...@gmail.com wrote:
BTW... the ToolTip is on a ToolStripItem and it seems to hold a
reference to the old form.

timn...@gmail.com wrote:
Nope. I don't have a handle to the tooltip. I have a handle to
the
form. I need to iterate the controls and their components and find
(using reflection since components are a private variable) the tool
tips.

On Jan 3, 9:38 am, "Architect" <Valen.Iva...@gmail.comwrote:
Hi,

To "unhook" a tooltip from a control call:

tooltip.SetToolTip(control, string.Empty);

To add it back:

tooltip.SetToolTip(control, "Your tooltip text");

You have to remove tooltip before you destroy the form and add it
back
when you create it again.

Regards,
Valentin Ivanov

On Jan 3, 9:08 am, timn...@gmail.com wrote:

I have an issue where I have a user control that is launched
into a
floating form. At some point later, I allow the user to
"unfloat"
the
user control by reparenting it on a split container in another
form.
Problem is if I wake a tooltip when the window is floated, and
then
try
the same thing when it is reparented, the app crashes with "
Cannot
access a disposed object.Object name: 'Form'.

Presumably, this is a result of the tooltips still keeping a
reference
to the original form (container).

I know that tooltips have to be found using reflection and the
controls
IContainer, but I am not sure how to go about this.

Is there a way to "reorient" all the tooltips to the new
container?
Jan 5 '07 #9

P: n/a
Hmm, for some reason my last reply is not here.

Anyways. The only way I made it to work is by recreating toolstrip control
each time I "migrate" the panel.

Regards,
Valentin Ivanov.

<ti*****@gmail.comwrote in message
news:11**********************@42g2000cwt.googlegro ups.com...
>I beg to differ. The start up form is "InitialForm" it never gets
closed. I ran this and it reproduces the error.

On Jan 3, 2:45 pm, "Architect" <valen.iva...@gmail.comwrote:
>Hi,

The example doesn't show the problem because you are closing main form
before showing the second form which will lead to application end.
But even in this example tooltip is not tied to a form so it should be
fine
to move panel around.

You can try it by commenting "Close();" call.

Regards,
Valentin Ivanov.

<timn...@gmail.comwrote in
messagenews:11**********************@a3g2000cwd.g ooglegroups.com...
Smallest example of issue below. Click the "open" button, hover over
the menu item to see the tool tip, click the "copy" button... now hover
over the menu item on the new form.... boom exception
--------- CUT HERE ----
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace ToolTipIssue
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new InitialForm());
}
}
public class InitialForm : Form
{
public InitialForm()
{
Button b = new Button();
b.Text = "Open Form";
Controls.Add(b);
b.Click += new EventHandler(b_Click);
}
void b_Click(object sender, EventArgs e)
{
MyForm f = new MyForm();
f.Show();
}
}
public class MyForm : Form
{
Panel p;
public MyForm()
{
p = new Panel();
ToolStrip t = new ToolStrip();
ToolStripButton b = new ToolStripButton();
b.Text = "Hello";
b.ToolTipText = "Hello ToolTip";
t.Items.Add(b);
p.BorderStyle = BorderStyle.Fixed3D;
p.Controls.Add(t);
Controls.Add(p);
Button bt = new Button();
bt.Text = "Copy";
bt.Click += new EventHandler(b_Click);
bt.Location = new System.Drawing.Point(0, 100);
Controls.Add(bt);
}
void b_Click(object sender, EventArgs e)
{
Form f = new Form();
f.Controls.Add(p);
Close();
f.Show();
}
}
}
On Jan 3, 11:31 am, timn...@gmail.com wrote:
BTW... the ToolTip is on a ToolStripItem and it seems to hold a
reference to the old form.
>timn...@gmail.com wrote:
Nope. I don't have a handle to the tooltip. I have a handle to the
form. I need to iterate the controls and their components and find
(using reflection since components are a private variable) the tool
tips.
On Jan 3, 9:38 am, "Architect" <Valen.Iva...@gmail.comwrote:
Hi,
To "unhook" a tooltip from a control call:
tooltip.SetToolTip(control, string.Empty);
To add it back:
tooltip.SetToolTip(control, "Your tooltip text");
You have to remove tooltip before you destroy the form and add it
back
when you create it again.
Regards,
Valentin Ivanov
On Jan 3, 9:08 am, timn...@gmail.com wrote:
I have an issue where I have a user control that is launched
into a
floating form. At some point later, I allow the user to
"unfloat"
the
user control by reparenting it on a split container in another
form.
Problem is if I wake a tooltip when the window is floated, and
then
try
the same thing when it is reparented, the app crashes with "
Cannot
access a disposed object.Object name: 'Form'.
Presumably, this is a result of the tooltips still keeping a
reference
to the original form (container).
I know that tooltips have to be found using reflection and the
controls
IContainer, but I am not sure how to go about this.
Is there a way to "reorient" all the tooltips to the new
container?
Jan 8 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.