I am writing a handheld program on CE 5.0 platform. There is a FormMain which contains a panel object, panel1. Once the FormMain is loaded the User Control Object, mainPanel will also be loaded into panel1. The mainPanel has a button, Entry. When user clicked the button, the mainPanel should be closed and other User Countrol Object, entryPanel will be loaded instead.
My question is how I can write some code on Enrty_Click method to trigger the FormMain.panel1 to remove the mainPanel and add the entryPanel instead.
Loading
Beo TsePosted Nov 25, 2010, 8:49 PM
// Program.cs
static class Program
{
....
public static mainPanel mp = new mainPanel();
public static entryPanel ep = new entryPanel();
....
}
// mainPanel.cs
....
private void Entry_Click(object sender, EventArgs e)
{
this.Parent.Controls.Add(Program.ep);
this.Parent.Controls.Remove(this);
}
....
// mainPanel.Designer.cs
....
this.Entry.Click += new System.EventHandler(this.Entry_Click);
....
Jason AkkermanPosted Nov 11, 2010, 2:36 PM
In C# it would look something like this:
EntryButton.Click += new EventHandler(EntryButton_Click); //add the handler to point to your code.
private void EntryButton_Click(object sender, EventArgs e) // your code that will execute with the button is clicked.
{
//do something
}
In VB.NET it would look something like this:
AddHandler EntryButton.Click, AddressOf EntryButton_Click 'add the handler to point to your code.
Private Sub EntryButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 'your code that will execute with the button is clicked.
'Do something
End Sub
In the example code where it says "Do something" you should put your code for removing and replacing the panel.
Good Luck.