'Class' does not contain a definition for 'TextBox1'

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,
I am writing a piece of code that creates a dynamic number of textboxes on
a form. Then I want to update them from another class in my project.

When I try I get a Compiler Error CS0117.
Here is some sample code:

Form1.cs:

FileWatcher fw = new FileWatcher();

public FileProcess()
{
//Code here for dynamically creating 5 text boxes.

fw.FileWatcherStart(this);
}


FileWatcher.cs:

public void FileWatcherStart(FileProcess myFileProcess)
{
myFileProcess.txtResults[1].Text = "MIKE";
}


If I comment out the textbox update line and step through my code and then
run the line: myFileProcess.txtResults[1].Text = "MIKE"; from the immediate
window, it works. Just wont run if i uncomment it. What do I need to do to
give my dynamically generated textboxes a definition?

Thanks,
Michael.
 
Back
Top