I have a usercontrol named as myUserControl.
1. myUserControl has a button.
2. The Constructor of myUserControl initializes a variable.
public partial class myUserControl : Usercontrol
{
public string test;
public myUserControl ()
{
InitializeComponent();
test = "This is test";
}
}
my Form1 has a flowlayout pannel.On my Form1.Load I add my myUserControl to a FLowLayoutPanel
private void Form1_Load(object sender, EventArgs e)
{
myUserControl muc = new myUserControl();
myFlowLayoutPannel.Controls.Add(muc);
}
now in Form1, i have a FlowlayoutPannel showing my myUserControl without an issue, what i want is when i click on the button of myUserControl, a Messagebox to be shown with the value of Test variable which defined in myUserControl.
I hope my idea is clear, of course, this is just an example to explain my question and your answer will help me to do something more.