我的项目中有3个ListViews和3个TextBox。如何将它们结合起来使用WinForms C#中的通用方法?
这是我的例子;
// My common method.
public void checkBarcode(System.Windows.Forms.TextBox txt_ProductName, System.Windows.Forms.ListView lst_Products)
{
//do some things
// At the end, i want to clear textbox and listbox of which product's button call this method
txt_ProductName.Clear();
lst_Products.Clear();
}
// My form members.
// How can i send textbox and listview objects below to my checkBarcode method?
private void btn_CheckEggBarcode_Click(object sender, EventArgs e)
{
checkBarcode(txt_Egg, lst_Products);
}
private void btn_CheckMilkBarcode_Click(object sender, EventArgs e)
{
checkBarcode(txt_Milk, lst_Milk);
}
private void btn_CheckChocloteBarcode_Click(object sender, EventArgs e)
{
checkBarcode(txt_Choclote, lst_Choclote);
}
字符串
1条答案
按热度按时间6yjfywim1#
尝试使用
Tag
属性字符串