What's the difference between creating a custom control by adding controls to a panel, for example, or adding the thing called UserControl from the Project->Add Windows Form wizard?
I'm trying to create a run-time custom control to a VS c# Windows Form program.
When I instantiate the UserControl from my main form, the subcontrols I placed in the UserControl designer
don't appear in the Intellisense selector:
UserControl UserControl1 = new UserControl();
UserControl1.<>
How do I set the subcontrol properties that are in UserControl1?
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "txt|*.txt|all|*.*";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
StreamReader inFile = new StreamReader(openFileDialog1.FileName);
while (!inFile.EndOfStream)
{
String inln = inFile.ReadLine();
UserControl UserControl1 = new UserControl();
UserControl1.label1 = inln; // This seems like the right place but Intellisense doesn't agree.
//
// The error: UserControl does not contain a definition for label1. Are you missing a using directive or assembly reference?
//
}
inFile.Close();
}
}
I like using VS, but it seems I'm always doing something just beyond my and its capability!
This post has been edited by codetonic: 10 November 2009 - 03:24 PM

New Topic/Question
Reply



MultiQuote




|