Passing Data between controls on different forms.

Hi,

I'm working on a spell checker web service.

I have a main form, and when something is searched it invokes the web service.

If the spelling appears incorrect then a frmSpell will load showing a suggestion.

E.g.

________________________

You searched for: Microosoft

Did you mean: Microsoft

         [YES]     [NO]
_________________________

The suggested spelling "Microsoft" is located on a label: lblSuggestion

When the user clicks YES I would like it so that the original search textbox text on frmMain equals that of lblSuggestion on frmSpell.

Can anyone help

Cheers!


Answer this question

Passing Data between controls on different forms.

  • kebo

    frmSpell SpellForm = new frmSpell(OriginalSearchTextbox.Text);

    if (SpellForm .ShowDialog() == DialogResult.OK)
            OriginalSearchTextbox.Text =  SpellForm.Suggestion;
    SpellForm.Dispose();


    you will need to add a string paramater to frmSpell's constructor:
    public frmSpell(string searchWord)

    and a property:
    public string Suggestion
    {
          get{return frmSpell.lblSuggestion.Text;}
    }

     

  • Marc.

    Thats awesome, worked perfectly :)
  • Passing Data between controls on different forms.