SelectCatagoryId
を含むというフォームがありますDataGridView
。cellvalue
ここから選択したものを別のフォームに渡したいAdd_product
。
これは、のボタンイベント内のコードですSelectcatagoryId
。
private void dataGridView1_MouseClick(object sender, MouseEventArgs e)
{
String dgv;
dgv = dataGridView1.CurrentCell.Value.ToString();
Add_product ap = new Add_product(dgv);
this.Close();
}
Add_product
これはフォーム内のコードです
namespace Supermarket
{
public partial class Add_product : Form
{
public Add_product()
{
InitializeComponent();
}
SqlConnection con;
string file;
public Add_product(String datagridvalue)
{
// MessageBox.Show(datagridvalue);
textBox10.Text = Convert.ToString(datagridvalue);
}
MessageBox
は正しく機能しています。フォームのdgvの値はフォームにselectCatagoryId
正しく渡されますが、変数の値をAdd_product
に割り当てることができません。datagridvalue
textBox10.Text