There is a class Unit: Label, instances of which are displayed on the Panel. It is necessary to make it so that you can add LineShape between elements that act as senders in MouseLeftButtonDown and MouseLeftButtonUp events . The catch is that you can only pass static methods to an EventHandler for an object, and you cannot add LineShape to a form from a static method . What's my mistake?
Z. Y. Do not judge strictly, in the WinForms I got the day before yesterday, and so far I do not focus on them at all.
UPD 1
static void MouseUp(object sender, MouseEventArgs e) { Unit from = start; // sender as Unit в MouseDown Unit to = sender as Unit; // проверки на null пока уберу Panel control = to.Parent as Panel; // как-то получить родителя start = null; LineShape line = new LineShape(from.Location.X, from.Location.Y, to.Location.X, to.Location.Y); control.Controls.Add(line); }
here in the last line the error Argument "1": type conversion from "Microsoft.VisualBasic.PowerPacks.LineShape" to "System.Windows.Forms.Control" is impossible.