I am really sorry if this question asked before, but I couldn't find a proper answer in internet. I have a main form inside there is a usercontrol that opens another form with below code:
public partial class OldForm: UserControl
{
public OldForm(FocusMoreMenu myFocusMore)
{
InitializeComponent();
}
private void createNewForm(object sender, EventArgs e)
{
NewForm newForm = new NewForm (this);
newForm .Show();
}
public void handleCloseEvent(object sender, FormClosedEventArgs e)
{
CustomToolTip notifyError = new CustomToolTip();
notifyError.Show("Some notification ", this, Xposition, Yposition, 2000);
}
}
In my new form I fill a string
variable. Press a button, close a form and try to transfer that string
variable to my old form.
public partial class NewForm : Form
{
OldForm oldFormObject;
public NewForm(OldForm oldFormObject)
{
this.oldFormObject = oldFormObject;
InitializeComponent();
}
private void closeButton(object sender, EventArgs e)
{
oldFormObject.passedVariable = someTextBox.Texts;
this.Close();
}
}
I can handle all these parts with out any problem. I also added a ClosedEvent as below:
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(oldFormObject.handleCloseEvent);
I can call the handleCloseEvent
with out any problem also. However when I add a breakpoint inside that function, I saw that NewForm
is still visible. In other words the handleCloseEvent doesn't called after the form closed.
You may say why this is a problem, It shouldn't matter that much. However it matters, because I created a Custom ToolTip class which creates a notification and it doesn't appear if another form is still exists. At least this is the high level understanding of my problem. Am I missing something?
How can I find a way to make my tooltip visible? There is no problem on making it visible if I don't create a new form like this.