PictureBox
으로 C#으로 이미지를 표시하고 싶습니다. 나는 contians가 pictureBox
인 타이머와 타이머를 만들었습니다. 하지만 그 때 아무것도에서 표시 개체를 만들 수 있습니다.이미지를 C#
어떻게해야합니까?
나는 정확하게 timer1을 사용합니까? Timer
가 활성화되어 있는지
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
c1 c = new c1();
c.create_move(1);
}
}
class c1 {
PictureBox p = new PictureBox();
Timer timer1 = new Timer();
public void create_move(int i){
p.ImageLocation = "1.png";
p.Location = new Point(50, 50 + (i - 1) * 50);
timer1.Start();
timer1.Interval = 15;
timer1.Tick += new EventHandler(timer_Tick);
}
private int k = 0;
void timer_Tick(object sender, EventArgs e)
{
// some code. this part work outside the class c1 properly.
...
}
어디로 넣어야합니까? move_create() 메서드에서 Form1.Controls.Add (p)를 작성했지만 오류가 발생했습니다. –
양식에 대한 참조가 필요합니다. 클래스의 생성자에서 속성을 전달하십시오. – Shimrod