|
樓主 |
發表於 14-11-30 20:27
|
顯示全部樓層
本帖最後由 googleandy 於 14-11-30 20:35 編輯
rich888 發表於 14-11-30 19:13
看來groupBox1.Controls在VB Net 是一個方法,在C#上是個屬性,我的作法
private void button1_Click(object ...
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;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//1.建立Label物件
Label[] lblCtl = new Label[5];
for (int i = 1; i <= 3; i++)
{
lblCtl = new Label();
}
for (int i = 1; i <= 3; i++)//!= lblStrkPrc.Length
{
//2.加入控制項
this.groupBox1.Controls.Add(lblCtl);
lblCtl.Text = "Label" ;
lblCtl.Top = Convert.ToInt32(20 + (lblCtl.Height * i * 1.3));
lblCtl.Height = 28;
lblCtl.Width = 115;
lblCtl.Left = 13;
lblCtl.BackColor = Color.Lime;
}
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
請教 rich888大,
程式開始就已動態加入 控制項(藍字)
請問, button1_Click要填入什麼程式才可達到前面所述的效果?
thanks.
|
|