G
Guest
I'm developping a windowsForms app in C#
As i created a lot of labels programmaticaly in the form_Load() ispecify the
following to manage the event in the same way for all of my labels:
So in this sub i wanted to call another form with a specific contructor
which set specific values from with the settings of the caller (obviously a
Label)
My code is the following:
private void _ChangeSettings(object sender, System.EventArgs e)
{
//MessageBox.Show(string.Concat("_changeSettings", sender.GetType(),
"//", sender.ToString() ));
//Load Form1 with the caller
if (sender.GetType().ToString() ==
"System.Windows.Forms.Label".ToString())
{System.Windows.Forms.Label lbl = sender;
Form1 f = new Form1(lbl);
f.Closed += new System.EventHandler(this._ChangeLabelSettings);
f.Show();}
}
when i'm building my solution i have the following error
Cannot implicitly convert type 'object' to 'System.Windows.Forms.Label'
How to convert object to Forms.Label????
Thanks for your help
As i created a lot of labels programmaticaly in the form_Load() ispecify the
following to manage the event in the same way for all of my labels:
So in this sub i wanted to call another form with a specific contructor
which set specific values from with the settings of the caller (obviously a
Label)
My code is the following:
private void _ChangeSettings(object sender, System.EventArgs e)
{
//MessageBox.Show(string.Concat("_changeSettings", sender.GetType(),
"//", sender.ToString() ));
//Load Form1 with the caller
if (sender.GetType().ToString() ==
"System.Windows.Forms.Label".ToString())
{System.Windows.Forms.Label lbl = sender;
Form1 f = new Form1(lbl);
f.Closed += new System.EventHandler(this._ChangeLabelSettings);
f.Show();}
}
when i'm building my solution i have the following error
Cannot implicitly convert type 'object' to 'System.Windows.Forms.Label'
How to convert object to Forms.Label????
Thanks for your help