evb中创建控件
如何在evb程序运行时动态创建控件,如textbox之类。
如有code,更好。
问题点数:100、回复次数:4Top
1 楼theng(手心忽然长出纠缠的曲线)回复于 2002-03-19 14:51:03 得分 0
等我想想,好像见过....(thinking in evb)Top
2 楼theng(手心忽然长出纠缠的曲线)回复于 2002-03-19 16:31:59 得分 0
用CreateWindowEx()吧Top
3 楼theng(手心忽然长出纠缠的曲线)回复于 2002-03-19 16:44:12 得分 100
下面是控件数组的sample,给分吧 ^_^
Option Explicit
Dim values() As Boolean
' Fake control array
Dim Check(7) As CheckBox
' Pass event handling off to a central function
Private Sub Check0_Click()
Check_Click 0
End Sub
Private Sub Check1_Click()
Check_Click 1
End Sub
Private Sub Check2_Click()
Check_Click 2
End Sub
Private Sub Check3_Click()
Check_Click 3
End Sub
Private Sub Check4_Click()
Check_Click 4
End Sub
Private Sub Check5_Click()
Check_Click 5
End Sub
Private Sub Check6_Click()
Check_Click 6
End Sub
Private Sub Check7_Click()
Check_Click 7
End Sub
' Handle the click event of all checkboxes here.
' We know which control this came from based on
' the passed parameter.
Private Sub Check_Click(index As Integer)
values(Scroll.Value + index) = Check(index).Value
End Sub
Private Sub Form_Load()
' Populate the fake control array
Set Check(0) = Check0
Set Check(1) = Check1
Set Check(2) = Check2
Set Check(3) = Check3
Set Check(4) = Check4
Set Check(5) = Check5
Set Check(6) = Check6
Set Check(7) = Check7
' Ask how many fields to display
Dim fields As Integer
fields = CInt(InputBox("你要多少就有多少?", _
"模拟", 20))
' Resize the 'values' array to hold
' a value for each field
ReDim values(fields)
' Configure the scroll bar for the given number
Scroll.Min = 1
Scroll.Value = 1
Scroll.Max = fields
' Update the UI
UpdateView
Me.Show
End Sub
Private Sub Scroll_Change()
UpdateView
End Sub
Private Sub UpdateView()
' For each viewable field in record mode
Dim f As Integer
Dim val As Boolean
For f = 0 To 7
' See if there is a value for this field number.
' If not, an "index out of bounds" error will
' be generated.
On Error Resume Next
val = values(Scroll.Value + f)
' If there is no field here
If Err.Number <> 0 Then
' hide the checkbox
Check(f).Visible = False
' If there is a field
Else
' Display its value on the form
Check(f).Value = val
' Give it an appropriate caption
Check(f).Caption = "Control #" & _
CStr(Scroll.Value + f)
' Make sure its visible
Check(f).Visible = True
End If
Next
End Sub
Private Sub Form_OKClick()
App.End
End Sub
Top
4 楼ljdyn()回复于 2002-03-20 17:39:13 得分 0
多谢。Top





