Good day guys, i have a problem on creating submenu's click menu, normally i can cast it on each of their properties but my submenus are from database and i dont know how to add the click event hardcoded
my code so far
void loadTechnicianData()
{
TechnicianPanel.Controls.Clear();
query = "SELECT * FROM `tbl_technician`";
using (MySqlConnection conn = constrings.GetDBConnection())
{
try
{
conn.Open();
using (MySqlCommand cmd = new MySqlCommand(query, conn))
{
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
Tech_UC uc = new Tech_UC();
uc.TechHeader.Text = reader["technician"].ToString();
uc.TechHeader.BackColor = Color.FromName(reader["color_assigned"].ToString());
uc.id = Convert.ToInt32(reader["t_id"].ToString());
TechnicianPanel.Controls.Add(uc);
ToolStripMenuItem cm = startToolStripMenuItem as ToolStripMenuItem;
cm.DropDownItems.Add(reader["technician"].ToString());
//here i need to call a click event to call a method void outside the loop
}
}
}
}
catch (Exception ex)
{
CMessageBox m = new CMessageBox("error\n" + ex);
m.ShowDialog();
}
finally
{
conn.Close();
}
}
}