Paul and Eran, thank you for answering me.
your answers helped me but i would like to explore also the possibility to
extends EventsArgs Class and to use events and delegates.
The important pieces of my small test program are :
//---------------------------------------------------------------
public class ExtendedEventArgs:EventArgs
{
bool OkIsClicked;
string data;
public ExtendedEventArgs()
{
OkIsClicked=false;
data="";
}
}
//-------------------------------------------------------------------
public delegate void myEventHandler(object sender,ExtendedEventArgs e);
//--------------------------------------------------------------------
this.button1.Click += new myEventHandler(this.button1_Click);
//----------------------------------------------
private void button1_Click(object sender, ExtendedEventArgs e)
{
MessageBox.Show("Hi everybody");
}
----------------------------------------------
When i try to compile this example the compiler gives me the following error
message.
<< Cannot implicitly convert type 'testEventargs.myEventHandler' to
'System.EventHandler'>>
What's wrong with that. Should i do any casting?
Thanks again.
Abdessamad.
"Paul E Collins" <fi******************@CL4.org> a écrit dans le message de
news:bt**********@titan.btinternet.com...
"Abdessamad Belangour" <be*******@irin.univ-nantes.fr> wrote:
form1 calls form2 [...]
The form1 needs to know which of form2
buttons were clicked and to get some form2
processed values . [...]
One way to do this is to add public properties to the second form and read
their values from the first form. They are readable even after the form
has been closed.
// code in MyForm1 (with a button MyButton)
private void MyButton_Clicked(object sender, EventArgs e)
{
MyForm1 frm = new MyForm1();
frm.ShowDialog();
string strValueFromForm2 = frm.TheValue;
frm.Dispose();
}
// code in MyForm2 (with a textbox MyTextBox)
public string TheValue
{
get { return m_strValue; }
}
private string m_strValue = "";
private void MyForm2_Closing(object sender, CancelEventArgs e)
{
// Remember what was in the textbox
m_strValue = MyTextBox.Text;
}
P.
--
www.CL4.org