Envoyer valeur cellule dataGridView d'une forme vers un TextBox

Résolu
aminaxy Messages postés 151 Date d'inscription jeudi 1 septembre 2011 Statut Membre Dernière intervention 18 août 2016 - Modifié par aminaxy le 11/06/2014 à 15:58
Whismeril Messages postés 19041 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 17 mai 2024 - 12 juin 2014 à 18:27
Bonjour,
j'ai un dataGridView dans Form4 et un TextBox dans Form6,est t'il possible d'envoyer la cellule sélectionnée de dataGridView vers le textBox,voici ce que j'ai fait mais j'ai pas de résultat dans le TextBox:

Code:

//dans la classe Form6

String sel;
private void button2_Click(object sender, EventArgs e)
{


if (form4.DataGridView.RowCount > 0) // controle si le dataGrid n'est pas vide
{
sel =(string)form4.DataGridView.Rows[0].Cells[0].Value;

}

string connectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Documents and Settings\\Administrateur\\Bureau\\WindowsFormsApplication1\\WindowsFormsApplication1\\AppData\\Base.mdf;Integrated Security=True;User Instance=True";

SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
SqlCommand sql = new SqlCommand("Update journal set intitule='" + textBox2.Text + "',numerotation='" + comboBox2.SelectedItem.ToString() + "',type='" + comboBox1.SelectedItem.ToString() + "',saisie_anal='" + checkBox1.Checked.ToString() + "',mise_sommeil='" + checkBox2.Checked.ToString() + "',note='" + textBox5.Text + "',stat'" + textBox6.Text + "');", connection);

connection.Close();
textBox1.Text = sel;
}

merci pour l'aide

3 réponses

jordane45 Messages postés 38178 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 16 mai 2024 344
11 juin 2014 à 18:40
1
Whismeril Messages postés 19041 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 17 mai 2024 656
11 juin 2014 à 20:37
1
aminaxy Messages postés 151 Date d'inscription jeudi 1 septembre 2011 Statut Membre Dernière intervention 18 août 2016
12 juin 2014 à 13:24
merci jordane45 et Whismeril pour l'aide :)
0
Whismeril Messages postés 19041 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 17 mai 2024 656
12 juin 2014 à 18:27
De rien
0
Rejoignez-nous