我想做什么:
- 通过表格上的条码搜索产品
Form1
; - 如果找不到:
1. 打开Inventory
表格 2. 按名称或描述搜索产品
3. 在ListView click
找到的产品上复制其条形码并将其粘贴到Form1
条形码文本框中。
所有这些都是正确完成的。问题是每次我从Inventory
表单添加产品时都会打开一个新产品。 Form1
这些值未在同一处处理Form1
,因此假设我销售 4 种产品:
- 其中2个是通过
Form1
条码搜索添加的 - 其中2个是通过
Inventory
搜索表单添加的
最后我得到了 3 个打开Form1
的表格,一个有 2 个产品,两个有单个产品的表格(通过Inventory
表格添加)。我需要它们合而为一。
谢谢
//-------------------------Form1---------- ----------------------
private void btnInventory_Click(object sender, EventArgs e)
{
Inventory Inventory = new Inventory();
Inventory.Show();
}
private string _theValue;
public string TheValue
{
get
{
return _theValue;
}
set
{
_theValue = value;
txtItems.Text = value;
}
}
// - - - - - - - - - - - - - - -存货 - - - - - - - - - ---------------
private void ShowForm1()
{
string value = label9.Text;
Form1 newForm = new Form1();
newForm.TheValue = value;
this.Close();
newForm.ShowDialog();
}
private void lvList_Click(object sender, EventArgs e)
{
label9.Text = lvList.SelectedItems[0].SubItems[0].Text;
this.ShowForm1();
}
抱歉耽搁了,我不得不等 8 小时才再次发帖
谢谢你的回复。
我刚试过 Form1
private void btnInventory_Click(object sender, EventArgs e)
{
Inventory _inv = new Inventory();
if (DialogResult.OK == _inv.ShowDialog())
{
txtItems.Text = _inv.fugi;
}
}
并以库存形式
private string test;
public string fugi
{
get { return test; }
set { test = label9.Text; }
}
private void lvList_Click(object sender, EventArgs e)
{
label9.Text = lvList.SelectedItems[0].SubItems[0].Text;
this.DialogResult = DialogResult.OK;
this.Close();
}
txtItems.Text没有从库存表单中获取test的值