Pass value from one form to another form in c#

后端 未结 2 1287
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-11 12:30

I have to pass id from one form to another from in C#.

I am not able to do this.

The C# code is:

private void btnedit_Click(obje         


        
2条回答
  •  醉话见心
    2020-12-11 13:18

    Make a property in AddInvoice:

    public long CellValue { get; set }
    

    Assign to it:

    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");
            }
        }
    

    And just use it in AddInvoice as CellValue.

    Oh, and if that's actually the code, I think you probably meant this.Hide(); instead of creating a new NonPaideData and hiding that.

提交回复
热议问题