什麼我嘗試做:複製粘貼從一種形式到其他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