I am trying to learn c#. I know how to code in php and understand what variables, functions, arrays, and all that are. The problem I am having is passing data. I was hoping that someone could give me a basic example that I cannot seem to get anywhere else. I want to have 2 pages on the same page if that makes any sense. The first page be a welcome screen with a button to the next page. The next page has a question with another button. I want the data to be passed from the first page to the second page and I want it to be on the same form (not open a new window. If that makes sense to anyone can you please give me an example. if you need clarification please ask.
Loading
Ryan AlfordPosted Jan 2, 2009, 1:45 PM
You can add controls to a form programmatically:
private void AddControlsToForm()
{
TextBox textBox1 = new TextBox();
textBox1.Name = "textBox1";
textBox1.Text = "Click Start";
textBox1.Location = new Point(91, 78);
textBox1.Size = new Size(100, 20);
Button btnStart = new Button();
btnStart.Text = "Start";
btnStart.Name = "btnStart";
btnStart.Location = new Point(101, 129);
btnStart.Size = new Size(75, 23);
btnStart.Click += new EventHandler(btnStart_Click);
this.Controls.Add(textBox1);
this.Controls.Add(btnStart);
this.ActiveControl = btnStart;
}
or, you can create all of the controls through the designer, and set the Visible property to true when you want to show them, or set it to false when you don't want to show them.
Nicholas GreenwoodPosted Jan 2, 2009, 11:05 AM
Ryan AlfordPosted Jan 2, 2009, 9:03 AM