2011-11-26 4 views
2

Visual Studio 2010을 사용 중입니다. Windows Form C# 응용 프로그램의 VB PowerPacks에서 OvalShapes를 여러 개 만들려고하지만 대신 수동으로 만들려는 도구 상자에서 끌어 오지 않습니다.Visual Basic Power Packs

using System; 
using System.Collections.Generic; 
System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using Microsoft.VisualBasic.PowerPacks; 
using System.Windows.Forms; 

namespace VB_PP 
{ 
    public partial class Form1 : Form 
    { 
    OvalShape[] OS_Arr; 
    public Form1() 
    { 
    InitializeComponent(); 
    OS_Arr = new OvalShape[15]; //I will do some coding on the array of those OvalShapes,like move them with a Timer... 
    } 
    } 
} 
+1

요요 자녀 컨트롤로 추가하는 것을 잊지 않으시겠습니까? 런타임에 추가하지 않고 디자인 타임에 추가한다고 가정합니다. 양식 디자이너를 사용하여 추가 한 다음 form.designer.cs 파일을 열고 행을 복사/붙여넣고 조정하십시오. – Mario

+0

아니, 런타임에 그들을 추가하고 싶습니다, 많이 고마워요 ... – YMELS

답변

3

당신이 원하는 것은 무엇인가이다, 문제는 내가 변수로 선언하는 경우, 그들은

코드 ... 내가 그들을 표시 감사를 할 수있는 방법, 양식에 나타나지 않을 것입니다 like :

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Windows.Forms; 
using Microsoft.VisualBasic.PowerPacks; 

namespace VBPowerPack 
{ 
    public partial class Form1 : Form 
    { 
     private ShapeContainer shapeContainer; //Container that you're gonna place into your form 
     private Shape[] shapes;     //Contains all the shapes you wanna display 

     public Form1() 
     { 
      InitializeComponent(); 

      shapes = new Shape[5];    //Let's say we want 5 different shapes 

      int posY = 0; 
      for (int i = 0; i < 5; i++) 
      { 
       OvalShape ovalShape = new OvalShape();  //Create the shape you want with it's properties 
       ovalShape.Location = new Point(50, posY); 
       ovalShape.Size = new Size(75, 25); 
       shapes[i] = ovalShape;      //Add the shape to the array 

       posY += 30; 
      } 

      shapeContainer = new ShapeContainer(); 
      shapeContainer.Shapes.AddRange(shapes);   //Add the array of shapes to the ShapeContainer 
      this.Controls.Add(shapeContainer);    //Add the ShapeContainer to your form 
     } 
    } 
}