110,538
社区成员
发帖
与我相关
我的任务
分享
类中用静态
public static string setFrmName(string s)
{
s= "新名称";
return s;
}
public class CommonFun
{
public static void setFrmName(Form frm)
{
frm.Text = "新名称";
.................
}
}
如果调用代码写在某个窗体中
public partial class FormA : Form
{
private void FormA _Load(object sender, EventArgs e)
{
CommonFun.setFrmName(this);//传入窗体参数
}
}
public class CommonFun
{
public static void setFrmName(frmBase frm)
{
frm.Text = "新名称";
.................
}
}
调用时
CommonFun.setFrmName(frm);