Rendering Lines as selectable Controls with properties

柔情痞子 提交于 2019-12-13 07:14:56

问题


I need to draw some lines, and they have very significant meaning to the content that will be linked to them.

How do I draw/render a Line (that has been drawn using GDI+) as a Control?

What I mean by that is, how do I draw a line that has its own properties, etc. For example, if while drawing the line, I will need to assign information to it, making it unique to all the other lines:

public void deleteSeletedLineButton_Click(object sender, EventArgs e)
{
   foreach(Line line in panel1.Lines)
   {
      if(line.Name == "lineNumber2")
      {
         line.Delete();
      {
   }
}

How an I set values to lines that I draw?:

myLine.SomeValue = "hooray!";

And, how can I make drawn lines/other shaped selectable (and movable/deletable/able to be enumerated)?

Are there better/easier ways to draw in C# than GDI?

来源:https://stackoverflow.com/questions/15278625/rendering-lines-as-selectable-controls-with-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!