請教VB2010動態控制項問題
如上圖,它是在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
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))
AddHandler CommandColor(i).Click, AddressOf Button1_Click
Next
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs)
If CType(sender, Button).Equals(CommandColor(0)) Then CommandColor(0).BackColor = Color.Red
If CType(sender, Button).Equals(CommandColor(1)) Then CommandColor(1).BackColor = Color.Green
If CType(sender, Button).Equals(CommandColor(2)) Then CommandColor(2).BackColor = Color.Yellow
End Sub
End Class試看看,我是VS2013寫的,應該差不多。
MTK 發表於 15-3-30 20:41 static/image/common/back.gif
試看看,我是VS2013寫的,應該差不多。
成功了, 非常感謝M大.
googleandy 發表於 15-3-30 21:23 static/image/common/back.gif
成功了, 非常感謝M大.
請問G大這些程式也是交易使用的嗎?
MTK 發表於 15-3-31 06:20 static/image/common/back.gif
請問G大這些程式也是交易使用的嗎?
計劃未來使用在選擇權交易上.
您知道的,撰擇權有太多商品,彼此又有關聯,
用單一Multicharts去處理,有相當大的困難度,
只好用algorithmic方法去研發.
不過,距離目標還有很長的路要走.....
頁:
[1]