0
我有一個名爲「customer.cs」的窗體,其中我有一個名爲「phonetxt」的文本框,我在名爲myclass.cs的模型中有一個類,我在「customer.cs」中有一行代碼 ,如何轉換字符串來控制「名稱」數據類型?
private void customerphone_Leave(object sender, EventArgs e)
{
if (customerphone.Text != "Enter Phone Number" && customerphone.Text == "")
{
this.customerphone.Text = "Enter Phone Number";
this.customerphone.ForeColor = Color.DarkGray;
errorcustomerphone.Icon = Properties.Resources.err;
errorcustomerphone.SetError(customerphone, "Enter Phone Number");
}
else
{
errorcustomerphone.Icon = Properties.Resources.ok;
errorcustomerphone.SetError(customerphone, "Enter Phone Number");
}
}
我想,這將在customer.cs調用
methodfortext("customerphone","errorcustomerphone","Enter PhoneNumber");
//that will send these parameters to myclass.cs
methodfortext(string controlname, string errorname , string name)
{
//i want
controlname.Text = name;
errorname.Icon = Properties.Resources.err;
}
有人請幫助我的方法,我在C#。希望新ü人得到了我想要的東西。