public void addDisciplineItem(Discipline newDiscipline) { DisciplineItem tmp = new DisciplineItem(newDiscipline); tmp.MouseUp += new MouseEventHandler(Discipline_Click); this.disciplinesPanel.Controls.Add(tmp); }
private void getData() { var repository = new DisciplineRepository(); //po odkomentowaniu nastepnej linijki sie wysypuje var disciplines = repository.GetAll(); foreach (Discipline discipline in disciplines) { DisciplineItem tmp = new DisciplineItem(discipline); tmp.MouseUp += new MouseEventHandler(Discipline_Click); this.disciplinesPanel.Controls.Add(tmp); } }
void Discipline_Click(Object sender, EventArgs e) { item = (DisciplineItem)sender; handle = item.getDiscipline(); MouseEventArgs me = (MouseEventArgs)e; if (me.Button == System.Windows.Forms.MouseButtons.Left) { var view = new DisciplineElements(handle); view.Show(); } if (me.Button == System.Windows.Forms.MouseButtons.Right) { metroContextMenu1.Show(System.Windows.Forms.Cursor.Position); } }