Hi all
i made a doubleclick event in a dataGridView, all i need to when i double click on row save the data in the row to a global List declered in a class file, and then change some labels text in another form depend on this List.
But what happens with me all thing is right after i make the 1st double click and close the 2nd form (that contans the labels) after i open the 2nd form again and do double click in the 1st form nothing happens, but when i do many clicks it works.
the code of the celldoubleclick:
- private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- GlobalVariables.CustomerInfoList.Add(dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells[0].Value.ToString());
- GlobalVariables.CustomerInfoList.Add(dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells[1].Value.ToString());
- GlobalVariables.CustomerInfoList.Add(dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells[2].Value.ToString());
- GlobalVariables.CustomerInfoList.Add(dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells[3].Value.ToString());
- GlobalVariables.CustomerInfoList.Add(dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells[7].Value.ToString());
- }
the code of global variables
- class GlobalVariables
- {
- public static string connectionString;
- public static string user = "User";
- public static string placeName = "";
- public static string permissions = "";
- public static List<string> CustomerInfoList = new List<string>();
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (GlobalVariables.CustomerInfoList.Count != 0)
- {
- customerIdNumberLabel.Text = GlobalVariables.CustomerInfoList[0];
- customerNameTB.Text = GlobalVariables.CustomerInfoList[1] + " " + GlobalVariables.CustomerInfoList[2] + " " + GlobalVariables.CustomerInfoList[3];
- mobileTB.Text = GlobalVariables.CustomerInfoList[4];
- customerIdNumberLabel.Visible = true;
- GlobalVariables.CustomerInfoList.Clear();
- }
- }

Amit GuptaRank #190 · 12.8K reputationPosted Aug 4, 2017, 3:00 PM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Aug 2, 2017, 11:15 AM EDT
Mohammed Gamal67 reputationPosted Aug 2, 2017, 12:45 PM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Aug 2, 2017, 12:57 PM EDT
Mohammed Gamal67 reputationPosted Aug 3, 2017, 10:18 PM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Aug 4, 2017, 4:08 AM EDT
Mohammed Gamal67 reputationPosted Aug 4, 2017, 12:30 PM EDT