|
如上圖,它是在VB6平台以”手工”建立的控制項
如果我想在VB2010平台,以”動態”建立控制項,並且達到一模一樣的結果,
請問應如何處理?
以下的程式碼,只是”動態”建立控制項的”基礎建設”而已,
請問,如何寫讓控制項變色那段程式?謝謝!
Public Class Form1
Dim CommandColor(2) As Button
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
For i = 0 To 2
CommandColor(i) = New Button
CommandColor(i).Text = "CommandColor" + Trim(Str(i))
CommandColor(i).ForeColor = Color.Black
CommandColor(i).Left = 50
CommandColor(i).Width = 250
CommandColor(i).Height = 50
CommandColor(i).Top = 50 + 66 * i
CommandColor(i).TextAlign = System.Drawing.ContentAlignment.MiddleCenter
CommandColor(i).Font = New Font(FontFamily.GenericSansSerif, 19, FontStyle.Regular)
CommandColor(i).BackColor = Color.Silver
Me.Controls.Add(CommandColor(i))
Next
End Sub
End Class
WindowsApplication1.rar
(62.74 KB, 下載次數: 193)
|
|