protected void LB_DoubleClick(object sender, EventArgs e) { //attempt to cast the sender as a label Label lbl = sender as Label; if (listBox3.Items.Contains(lbl.Name)) { Form8 frm = new Form8(lbl.Name); frm.Show(); } }
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) { string city = dataGridView1.CurrentCell.Value.ToString(); MySqlConnection connection = new MySqlConnection(sqlcon); connection.Open(); MySqlCommand command = connection.CreateCommand(); MySqlDataReader reader; command.CommandText = "SELECT * FROM regions where name=@p1"; command.Prepare(); command.Parameters.AddWithValue("@p1", city); reader = command.ExecuteReader(); reader.Read(); string owner = Convert.ToString(reader["owner"]); reader.Close(); if(owner == textBox1.Text) { Form8 frm = new Form8(city); frm.Show(); } } }
private void listBox3_MouseDoubleClick(object sender, MouseEventArgs e) { string text = listBox3.GetItemText(listBox3.SelectedItem); Form8 frm = new Form8(text); frm.Show(); }