【问题标题】:Label for Line Shape at Visual Basic Power Pack tools in c# win Appc# win App 中 Visual Basic Power Pack 工具中线条形状的标签
【发布时间】:2013-03-16 06:57:31
【问题描述】:

Line shape是VisualBasic power pack 1.0(在vs2010中)的工具之一,

当我将标签属性添加到容器控件时,如何定义标签属性并为其设置值:

我的代码低于并且(在设计时)需要

public class MyLine:Microsoft.VisualBasic.PowerPacks.LineShape
{
    public Label label ;
    public MyLine()
    {
    }       
    public MyLine(ShapeContainer container)
        : base(container)
    {
        label = new Label() { Text = "Ali_Sarshogh" };
    }
}

///--------- 以主表单调用:

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);

结果:表格上画线但标签不可见

【问题讨论】:

    标签: c# winforms label winapp vb-power-pack


    【解决方案1】:

    给标签一个大小和位置,并将它也添加到控件中。比如:

    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);
    }
    

    查看您创建的表单的任何 Designer.cs 文件,您将了解 IDE 是如何执行此操作的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-22
      • 2018-11-25
      • 1970-01-01
      • 2020-11-07
      • 1970-01-01
      • 2015-01-11
      • 1970-01-01
      相关资源
      最近更新 更多