Passing data from a DataGridView to TextBoxes in C #

0

Hello, I'm having a problem and I've even asked a similar question previously, but now I'm being more specific.

I have two forms, one form has a DataGridView attached to one Database and the other form will serve as an edit for the data of the records shown in that DataGridView.

For this to occur, the user will select a row with a DataGridView record and click the Edit button, which will open the other form.

I do not know how to do the following part: I need to pass the data from the records that are in the dataGridView in the main form to the textBoxes of the edit form, so that it is possible to change this data.

If anyone can help, I'll be grateful = D I'm using Windows Form.

    
asked by anonymous 15.10.2016 / 02:16

1 answer

0
    //ESTE É O FORM DA EDIÇÃO 
    public partial class frm_edit : Form
     {
         public string Nome;
         public int Idade;
     }

       // este é o evento load do form da edição
    private void frm_edit_Load(object sender, EventArgs e)
    {
         txtNome.Text=Nome;
         txtIdade.Text=Idade+"";
    }


    // AQUI NO FORM ONDE ESTA A DataGridView1  NO CLICK DO BOTÃO 
     {

       frm_edit  FE=new frm_edit();

      FE.Nome= Convert.ToString(DataGridView1[0,DataGridView.CurrentRow.Index].Value);
      FE.Idade= Convert.ToInt32(DataGridView1[1,    DataGridView.CurrentRow.Index].Value);

      FE.Show();

The numbers 0 and 1 are the columns, in this case:

0-Name  1-Age

}

    
15.10.2016 / 02:41