let's say i have a form and his child and i want the child to trigger his father without them knowing each other in other words i want the child to be generic
for example let's say i have a form button and a richTextBox and i want with evey click to change the richTextBox text
i want form and button to not know each other how can i do it ? i tries this one :
public partial class Form1 : Form
{
delegate void myfatherDelgate();
static int msgCounter = 0 ;
public Form1()
{
InitializeComponent();
button1 = new myButton();
myfatherDelgate += myMethod();
}
public void myMethod()
{
switch (msgCounter)
{
case 1:
{
richTextBox1.Text = "first click";
msgCounter++;
}
case 2:
{
richTextBox1.Text = "second click";
}
defult: this.Close;
}
}
}
public class mybutton : Button { static int myint;
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
this.Parent.Invoke(myfatherDelgate());
}
}
the easiest way is to do :
private void button1_Click(object sender, EventArgs e)
{
switch (msgCounter)
{
case 1:
{
richTextBox1.Text = "first click";
msgCounter++;
}
case 2:
{
richTextBox1.Text = "second click";
}
defult: this.Close;
}
}
in the father form ...
I think my all concept is crap can someone in light me ? but i mistake here and it's circular can someone help me here ?...