Label for Line Shape at Visual Basic Power Pack tools in c# win App

1.8k Views Asked by At

The Line shape is one of tools of VisualBasic power pack 1.0 (in vs2010) ,

How can I define a label property and set value to it when I add it to a container control:

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

1

There are 1 best solutions below

0
On BEST ANSWER

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.