.net design pattern question
- by user359562
Hi.
I am trying to understand design pattern problems. I am trying to modify the code like this in winforms and trying to see if any design pattern suits my requirement. Please suggest which is the best design pattern in this scenario. This is very basic code containing 2 tab pages which might have different controls can be added dynamically and read out different files on click of particular tab. To elaborate more... I have written this code to learn and understand design pattern. This is just a scenario where user click on a particular tab which will show dynamic controls generated.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedTab.Name.Equals("tabPage1"))
{
GeneratedynamicControlsForTab1();
}
else if (tabControl1.SelectedTab.Name.Equals("tabPage2"))
{
GeneratedynamicControlsForTab2();
}
}
private void GeneratedynamicControlsForTab1()
{
Label label1 = new Label();
label1.Text = "Label1";
tabPage1.Controls.Add(label1);
ReadCSVFile();
}
private void GeneratedynamicControlsForTab2()
{
tabPage1.Controls.Clear();
Label label2 = new Label();
label2.Text = "Label2";
tabPage2.Controls.Add(label2);
ReadTextFile();
}
private void ReadCSVFile()
{
}
private void ReadTextFile()
{
}
}