Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Help me please ...

Help me please ...

Scheduled Pinned Locked Moved C#
helpquestionlearning
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SRJ92
    wrote on last edited by
    #1

    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 ?

    X D D 3 Replies Last reply
    0
    • S SRJ92

      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 ?

      X Offline
      X Offline
      Xmen Real
      wrote on last edited by
      #2

      did you set frmFindReplace property ? if yes, you should show InsertText code

      TVMU^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%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia>

      ----------------------------------------------- 128 bit encrypted signature, crack if you can

      1 Reply Last reply
      0
      • S SRJ92

        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 ?

        D Offline
        D Offline
        dan sh
        wrote on last edited by
        #3

        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.

        S 1 Reply Last reply
        0
        • S SRJ92

          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 ?

          D Offline
          D Offline
          DaveyM69
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • D dan sh

            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.

            S Offline
            S Offline
            SRJ92
            wrote on last edited by
            #5

            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();
                }
            
            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups