[英]Label for Line Shape at Visual Basic Power Pack tools in c# win App
The Line shape is one of tools of VisualBasic power pack 1.0 (in vs2010) , Line形状是VisualBasic power pack 1.0的工具之一(在vs2010中),
How can I define a label property and set value to it when I add it to a container control: 当我将它添加到容器控件时,如何定义label属性并为其设置值:
My code is below and ( at Design time ) need 我的代码在下面和(在设计时)需要
public class MyLine:Microsoft.VisualBasic.PowerPacks.LineShape
{
public Label label ;
public MyLine()
{
}
public MyLine(ShapeContainer container)
: base(container)
{
label = new Label() { Text = "Ali_Sarshogh" };
}
}
///--------- call in master form : /// ---------以主表格调用:
private Microsoft.VisualBasic.PowerPacks.ShapeContainer shapeContainer1;
//--- in Button1_Click() i want to draw it :
MyLine lineShape1 = new MyLine(shapeContainer1);
lineShape1.Name = "lineShape1";
lineShape1.X1 = 25;
lineShape1.X2 = 160;
lineShape1.Y1 = 18;
lineShape1.Y2 = 17;
this.shapeContainer1.Shapes.Add(lineShape1);
result: The line is drawn on the form but label isn't visible 结果:该行在表单上绘制,但标签不可见
Give the label a size and location, and add it to the control too. 为标签指定大小和位置,并将其添加到控件中。 Something like: 就像是:
public MyLine(ShapeContainer container) : base(container)
{
label = new Label() { Text = "Ali_Sarshogh" };
label.Location = new Point(0, 0);
label.Size = new Size(100, 14);
this.Controls.Add(label);
}
Take a looks at any Designer.cs
file for a form you've created, and you'll see how the IDE does it. 查看您创建的表单的任何Designer.cs
文件,您将看到IDE如何执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.