Help me please ...
-
ok, here goes, i have been stuck on this for hours and getting no further so i thought i would ask you lot .... ok basically all this program is doing is when something is entered into txtfind (on form frmfindandreplace [form 2] ) it will be then pasted into a richtextbox ... this is named InsertText. This is on form 1 of course ... so i am transferring the string from frmfindandreplace to form 1... here is my code...(i have edited it to make it smaller so that you can see my problem more clearer) frmFindReplace
public string findme
{
get { return txtfind.Text; }
set { txtfind.Text = value; }
}
private void bnFind_Click(object sender, EventArgs e)
{
if (Clicked != null)
Clicked(true);
}Form 1
public frmFindReplace frmFindReplace{get;set;}
public window()
{
void find_Clicked(bool Yes)
{
InsertText(frmFindReplace.findme);
}
}thanks for all your help ... i keep getting the error message about it being a null value .... why ?
-
ok, here goes, i have been stuck on this for hours and getting no further so i thought i would ask you lot .... ok basically all this program is doing is when something is entered into txtfind (on form frmfindandreplace [form 2] ) it will be then pasted into a richtextbox ... this is named InsertText. This is on form 1 of course ... so i am transferring the string from frmfindandreplace to form 1... here is my code...(i have edited it to make it smaller so that you can see my problem more clearer) frmFindReplace
public string findme
{
get { return txtfind.Text; }
set { txtfind.Text = value; }
}
private void bnFind_Click(object sender, EventArgs e)
{
if (Clicked != null)
Clicked(true);
}Form 1
public frmFindReplace frmFindReplace{get;set;}
public window()
{
void find_Clicked(bool Yes)
{
InsertText(frmFindReplace.findme);
}
}thanks for all your help ... i keep getting the error message about it being a null value .... why ?
did you set
frmFindReplace
property ? if yes, you should showInsertText
codeTVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN% R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
----------------------------------------------- 128 bit encrypted signature, crack if you can
-
ok, here goes, i have been stuck on this for hours and getting no further so i thought i would ask you lot .... ok basically all this program is doing is when something is entered into txtfind (on form frmfindandreplace [form 2] ) it will be then pasted into a richtextbox ... this is named InsertText. This is on form 1 of course ... so i am transferring the string from frmfindandreplace to form 1... here is my code...(i have edited it to make it smaller so that you can see my problem more clearer) frmFindReplace
public string findme
{
get { return txtfind.Text; }
set { txtfind.Text = value; }
}
private void bnFind_Click(object sender, EventArgs e)
{
if (Clicked != null)
Clicked(true);
}Form 1
public frmFindReplace frmFindReplace{get;set;}
public window()
{
void find_Clicked(bool Yes)
{
InsertText(frmFindReplace.findme);
}
}thanks for all your help ... i keep getting the error message about it being a null value .... why ?
That is because the property frmFindReplace is null. Are you setting that property somewhere? How are you opening the FindReplace form? You will need to keep that instance of the form in the Form1 to access the correct value of the property findme in the form1.
-
ok, here goes, i have been stuck on this for hours and getting no further so i thought i would ask you lot .... ok basically all this program is doing is when something is entered into txtfind (on form frmfindandreplace [form 2] ) it will be then pasted into a richtextbox ... this is named InsertText. This is on form 1 of course ... so i am transferring the string from frmfindandreplace to form 1... here is my code...(i have edited it to make it smaller so that you can see my problem more clearer) frmFindReplace
public string findme
{
get { return txtfind.Text; }
set { txtfind.Text = value; }
}
private void bnFind_Click(object sender, EventArgs e)
{
if (Clicked != null)
Clicked(true);
}Form 1
public frmFindReplace frmFindReplace{get;set;}
public window()
{
void find_Clicked(bool Yes)
{
InsertText(frmFindReplace.findme);
}
}thanks for all your help ... i keep getting the error message about it being a null value .... why ?
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...
// TextEventArgs.cs
using System;public class TextEventArgs : EventArgs
{
private string text;public TextEventArgs(string text) { this.text = text; } public string Text { get { return text; } }
}
// 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); }
}
// 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 -
That is because the property frmFindReplace is null. Are you setting that property somewhere? How are you opening the FindReplace form? You will need to keep that instance of the form in the Form1 to access the correct value of the property findme in the form1.
how do i store the property ? and i am opening the form as follows :
private void findAndReplaceToolStripMenuItem\_Click(object sender, EventArgs e) { frmFindReplace find = new frmFindReplace(); find.Clicked += new ButtonClick(find\_Clicked); find.ShowDialog(); }