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に割り当てることができません。datagridvaluetextBox10.Text