I have a one small problem, I have a class, where I have :
public void errRaise(string msg)
{
if (error == "")
{
error = msg;
}
// I would like to write on a label1 on Form1 a msg.
}
I know how to access label1 from Form1, but I dont know how to realize that in a class, please, help.
Santhosh NPosted Dec 30, 2009, 11:22 AM
MeiPosted Dec 30, 2009, 10:23 AM
Kirtan PatelPosted Dec 30, 2009, 6:35 AM
Friend,
Here is your Solution !!!
if you find my answer use full then please check "Do you like this answer" check box :)
//Import the Following Name space in Class
using System.Windows.Forms;
//Now Write Function Like this
public void errRaise(string msg,Label lbl)
{
if (error == "")
{
lbl.Text = msg;
}
}
// Here is How to Use the Function
// Suppose you want to Set error on Form's Label 1
then call it like below in form
Class1 c1 = new Class1();
c1.errRais("Error Message Here",Label1);
Santhosh NPosted Dec 30, 2009, 6:31 AM
I would suggest you to return the error msg in the function and assing this to the label control in the form as you will have that use in that only but not in the class