什么我尝试做:复制粘贴从一种形式到其他C#
- 搜索产品按条码上
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();
}
对不起˚F或延迟,我不得不等待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。文字不从库存的形式得到测试的价值
请检查我的更新答案,你可能会发现你可以发表评论给我的答案 – Sayse