Click here to Skip to main content
16,007,610 members
Home / Discussions / C#
   

C#

 
GeneralRe: Closing only the applications, not the windows processes Pin
Luc Pattyn21-Jun-10 3:12
sitebuilderLuc Pattyn21-Jun-10 3:12 
GeneralRe: Closing only the applications, not the windows processes Pin
teknolog12321-Jun-10 23:47
teknolog12321-Jun-10 23:47 
GeneralRe: Closing only the applications, not the windows processes Pin
PIEBALDconsult20-Jun-10 17:06
mvePIEBALDconsult20-Jun-10 17:06 
QuestionHelp me please ... Pin
SRJ9220-Jun-10 7:30
SRJ9220-Jun-10 7:30 
AnswerRe: Help me please ... Pin
Xmen Real 20-Jun-10 8:11
professional Xmen Real 20-Jun-10 8:11 
AnswerRe: Help me please ... Pin
dan!sh 20-Jun-10 9:18
professional dan!sh 20-Jun-10 9:18 
GeneralRe: Help me please ... Pin
SRJ9220-Jun-10 11:03
SRJ9220-Jun-10 11:03 
AnswerRe: Help me please ... Pin
DaveyM6920-Jun-10 10:00
professionalDaveyM6920-Jun-10 10:00 
There's a few things that you haven't shown that could be the problem but rather than guess at that I would suggest an easier way. Why not just raise an event and pass the text in the arguments back to the main form? Something like...
C#
// TextEventArgs.cs
using System;

public class TextEventArgs : EventArgs
{
    private string text;

    public TextEventArgs(string text)
    {
        this.text = text;
    }

    public string Text
    {
        get { return text; }
    }
}

C#
// FormFindAndReplace.cs
using System;
using System.Windows.Forms;

public partial class FormFindAndReplace : Form
{
    public event EventHandler<TextEventArgs> FindClicked;

    public FormFindAndReplace()
    {
        InitializeComponent();
    }

    private void buttonFind_Click(object sender, EventArgs e)
    {
        OnFindClicked(new TextEventArgs(textBox.Text));
    }

    protected virtual void OnFindClicked(TextEventArgs e)
    {
        EventHandler<TextEventArgs> eh = FindClicked;
        if (eh != null)
            eh(this, e);
    }
}

C#
// FormMain.cs
using System;
using System.Windows.Forms;

public partial class FormMain : Form
{
    private FormFindAndReplace formFindAndReplace = null;

    public FormMain()
    {
        InitializeComponent();
    }

    private void findAndReplaceToolStripMenuItem_Click(object sender, EventArgs e)
    {
        if (formFindAndReplace == null)
            formFindAndReplace = new FormFindAndReplace();
        formFindAndReplace.FindClicked += formFindAndReplace_FindClicked;
        formFindAndReplace.FormClosing += formFindAndReplace_FormClosing;
        formFindAndReplace.Show();
    }

    private void formFindAndReplace_FindClicked(object sender, TextEventArgs e)
    {
        // Do your thing with e.Text
        Console.WriteLine(e.Text);
    }
    private void formFindAndReplace_FormClosing(object sender, FormClosingEventArgs e)
    {
        formFindAndReplace.FormClosing -= formFindAndReplace_FormClosing;
        formFindAndReplace.FindClicked -= formFindAndReplace_FindClicked;
        formFindAndReplace = null;
    }
}

Dave

If this helped, please vote & accept answer!


Binging is like googling, it just feels dirtier. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

QuestionSingleton Pattern Alternative Pin
Brendan Vogt20-Jun-10 4:33
Brendan Vogt20-Jun-10 4:33 
AnswerRe: Singleton Pattern Alternative Pin
Not Active20-Jun-10 4:50
mentorNot Active20-Jun-10 4:50 
GeneralRe: Singleton Pattern Alternative Pin
Brendan Vogt20-Jun-10 5:10
Brendan Vogt20-Jun-10 5:10 
GeneralRe: Singleton Pattern Alternative Pin
Not Active20-Jun-10 9:25
mentorNot Active20-Jun-10 9:25 
AnswerRe: Singleton Pattern Alternative Pin
PIEBALDconsult20-Jun-10 7:12
mvePIEBALDconsult20-Jun-10 7:12 
GeneralRe: Singleton Pattern Alternative Pin
J4amieC20-Jun-10 22:08
J4amieC20-Jun-10 22:08 
GeneralRe: Singleton Pattern Alternative Pin
PIEBALDconsult21-Jun-10 2:47
mvePIEBALDconsult21-Jun-10 2:47 
AnswerRe: Singleton Pattern Alternative Pin
yu-jian27-Jun-10 10:05
yu-jian27-Jun-10 10:05 
QuestionMouseEventArgs + Datagridview [Solved] Pin
jojoba201119-Jun-10 20:38
jojoba201119-Jun-10 20:38 
AnswerRe: MouseEventArgs + Datagridview Pin
I Believe In GOD20-Jun-10 5:17
I Believe In GOD20-Jun-10 5:17 
AnswerRe: MouseEventArgs + Datagridview Pin
jojoba201120-Jun-10 7:47
jojoba201120-Jun-10 7:47 
Questionhow Icould use messagebox result? Pin
ronakT19-Jun-10 20:28
ronakT19-Jun-10 20:28 
AnswerRe: how Icould use messagebox result? Pin
DaveAuld19-Jun-10 20:39
professionalDaveAuld19-Jun-10 20:39 
AnswerRe: how Icould use messagebox result? Pin
Xmen Real 20-Jun-10 8:14
professional Xmen Real 20-Jun-10 8:14 
AnswerRe: how Icould use messagebox result? Pin
Abhinav S19-Jun-10 20:40
Abhinav S19-Jun-10 20:40 
AnswerRe: how Icould use messagebox result? Pin
yu-jian27-Jun-10 10:08
yu-jian27-Jun-10 10:08 
AnswerRe: how Icould use messagebox result? Pin
kumar16921-Oct-10 21:48
kumar16921-Oct-10 21:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.