一個DataGridView我要送的從FormB 2個文本框,當我在「驗證布通」在形式上在DataGridView CLIC的價值;這是我嘗試代碼:發送文本框的值在形式上
FormB:
namespace RibbonDemo.Fichier
{
public partial class NvFamillImmo : Form
{
public event BetweenFormEventHandler BetweenForm;
SqlDataAdapter dr;
DataSet ds = new DataSet();
string req;
public NvFamillImmo()
{
InitializeComponent();
affich();
}
private void button2_Click(object sender, EventArgs e) //the validate buton
{
if (BetweenForm != null)
BetweenForm(textBox1.Text, textBox2.Text);
}
private void fillByToolStripButton_Click(object sender, EventArgs e)
{
try
{
this.amortissementFiscalTableAdapter.FillBy(this.mainDataSet.amortissementFiscal);
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
}
}
,這是備考:
namespace RibbonDemo.Fichier
{
public delegate void BetweenFormEventHandler(string txtbox1value, string txtbox2value);
public partial class FammileImm : Form
{
private NvFamillImmo nvFamillImmo;
public FammileImm()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
NvFamillImmo frm2 = new NvFamillImmo();
frm2.BetweenForm += frm2_BetweenForm;
frm2.ShowDialog();
}
void frm2_BetweenForm(string txtbox1value, string txtbox2value)
{
//dataGridView1.Refresh();
String str1 = nvFamillImmo.textBox1.Text.ToString();
this.dataGridView1.Rows[0].Cells[0].Value = str1;
}
}
}
編輯:我填的方法frm2_BetwwenForm但現在我得到參考的一個問題 感謝幫助
我認爲你錯過了你必須添加一個新行的想要datagridview的值的部分。那會我們在frm2_BetweenForm(...) – fabricio
感謝法布里西奧我已編輯frm2_Between ..方式類似: – Lina
無效frm2_BetweenForm(字符串txtbox1value,串txtbox2value) { 字符串STR1 = nvFamillImmo.textBox1.Text.ToString() ; //此行中的問題 this.dataGridView1.Rows [0] .Cells [0] .Value = str1; }但我得到的基準問題 – Lina