C# 在c语言中,将值从一种形式传递到另一种形式
我必须用C语言将id从一个表单传递到另一个表单 我不能这样做 C代码是:C# 在c语言中,将值从一种形式传递到另一种形式,c#,winforms,C#,Winforms,我必须用C语言将id从一个表单传递到另一个表单 我不能这样做 C代码是: private void btnedit_Click(object sender, EventArgs e) { foreach (DataGridViewRow a in dataGridViewUnPaidList.Rows) { if (a.Cells[0].Value != null) { Convert.ToInt64(a.Cells[1]
private void btnedit_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow a in dataGridViewUnPaidList.Rows)
{
if (a.Cells[0].Value != null)
{
Convert.ToInt64(a.Cells[1].Value); // i have to pass this id in AddInvoice() form
AddInvoice ad = new AddInvoice();
ad.Show();
NonPaideData non = new NonPaideData();
non.Hide();
}
else
{
MessageBox.Show("Now Row Is Selected");
}
}
}
有人能告诉我我做错了什么吗?另外创建一个属性:
分配给它:
private void btnedit_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow a in dataGridViewUnPaidList.Rows)
{
if (a.Cells[0].Value != null)
{
AddInvoice ad = new AddInvoice();
ad.CellValue = Convert.ToInt64(a.Cells[1].Value);
ad.Show();
NonPaideData non = new NonPaideData();
non.Hide();
}
else
{
MessageBox.Show("Now Row Is Selected");
}
}
只需在AddInvoice中将其用作CellValue
哦,如果这就是代码,我想你可能是这个意思;不要创建新的非辅助数据并将其隐藏。在AddInvoice中创建属性:
分配给它:
private void btnedit_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow a in dataGridViewUnPaidList.Rows)
{
if (a.Cells[0].Value != null)
{
AddInvoice ad = new AddInvoice();
ad.CellValue = Convert.ToInt64(a.Cells[1].Value);
ad.Show();
NonPaideData non = new NonPaideData();
non.Hide();
}
else
{
MessageBox.Show("Now Row Is Selected");
}
}
只需在AddInvoice中将其用作CellValue
哦,如果这就是代码,我想你可能是这个意思;而不是创建新的非助手数据并将其隐藏在Form1中。
private void ShowForm2()
{
string value = TheTextBox.Text;
Form2 newForm = new Form2();
newForm.TheValue = value;
newForm.ShowDialog();
}
表格2
private string _theValue;
public string TheValue
{
get
{
return _theValue;
}
set
{
_theValue = value;
// do something with _theValue so that it
// appears in the UI
}
}
看到这段代码,我想这会对您有所帮助。格式1
private void ShowForm2()
{
string value = TheTextBox.Text;
Form2 newForm = new Form2();
newForm.TheValue = value;
newForm.ShowDialog();
}
表格2
private string _theValue;
public string TheValue
{
get
{
return _theValue;
}
set
{
_theValue = value;
// do something with _theValue so that it
// appears in the UI
}
}
看到这个代码,我想这会对你有所帮助