Skip to content

Change a value in a form from a different class

Jan

Asked May 8, 2006, 1:16 AM EDT1 answer
Share
LinkedInX
I have create a windows form frmAccount, in the form a have a richtextbox "rtxtLastScan" from the form I call (FileDirectory fd = new FileDirectory(); fd.timer(int.Parse(rtxtSeconds.Text), rtxtAccount.Text, strStartUpPath);) another class FileDirectory.cs. From this class i want to set rtxtLastScan´s value, I tried different ways but nothing seems to work. When i debugg i got down to ScanDirectory() and the code runs tro but the text in frmAccount rtxtLastScan doesn´t change. Could anyone help me? public class FileDirectory { string strStartUpPath = ""; Account myAcc = new Account(); frmAccount myFrmAccount; public void ScanDirectory() { myFrmAccount = new frmAccount(); myFrmAccount.rtxtLastScan.Text = "Hello"; } }

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • +1
    Pass a reference to the other form to the form you call your function from. Then use the reference to make the change in the form.
    +1