IDE: VS 2010、c# .net 4.0、Winforms
正如我们所知道的,我们可以通过以下方式找到使用name的控件
面板控件示例:
Control[] c = this.Controls.find("panel1", true);
if(c.length>1)
{
Panel p = c[0] as Panel;
} 上面的代码工作正常。
与我用于矩形形状控制的代码相同,名称空间是
{Microsoft.VisualBasic.PowerPacks.RectangleShape} 我在名为"rectangleShapeMonthCalender“的表单上添加了矩形
Control[] c = this.Controls.find("rectangleShapeMonthCalender", true);
if(c.length>1) //here I am getting length of control array 0, i.e control not found.
{
Microsoft.VisualBasic.PowerPacks.RectangleShape shape= c[0] as Panel;
} 您能告诉我如何找到驻留在
"Microsoft.VisualBasic.PowerPacks" 命名空间,所以我可以解决上面的问题。
发布于 2015-08-20 20:39:47
形状,如矩形,椭圆等驻留在shapecontainers中,所以每当我们在表单中添加矩形时,shapecontainer就会自动添加到该表单上。
要找到该矩形,请使用以下代码:
int totalItems = shapeContainer1.Shapes.Count;
for (int i = 0; i < totalItems; i++)
{
Shape s = container.Shapes.get_Item(i) as Shape;
}https://stackoverflow.com/questions/30891790
复制相似问题