动态生成控件并定位
2012-03-10 10:54
316 查看
Public Class form1
Private a(0 To 8) As Control
Private b(0 To 8) As Object
Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
For i As Int16 = 0 To 8
If i < 3 Then
b(i) = New Int16
b(i) = 5
Debug.WriteLine(CType(b(i), Integer) & " 是" & TypeName(b(i)), ToString)
ElseIf i < 6 Then
b(i) = New String(CType("Welcome", Char()))
b(i) = "Welcome"
Debug.WriteLine(CType("Welcome", Char()) & " 是" & TypeName(b(i)), ToString)
ElseIf i < 7 Then
b(i) = New Label With {.BorderStyle = BorderStyle.Fixed3D, .Size = New Size(60, 60), .Location = New Point(60, 220)}
Controls.Add(CType(b(i), Control))
If TypeOf b(i) Is Label Then
Debug.WriteLine(TypeName(b(i)) & "是标签", ToString)
End If
End If
Next
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ReDim a(0 To 8)
For i As Int16 = 0 To 8
If i < 3 Then
a(i) = New Label With {.BorderStyle = BorderStyle.Fixed3D, .Size = New Size(60, 60), .Location = New Point(i * 60, 0)}
Controls.Add(a(i))
ElseIf i < 6 Then
a(i) = New Button With {.Size = New Size(60, 60), .Location = New Point((i - 3) * 60, 70)}
Controls.Add(a(i))
ElseIf i < 9 Then
a(i) = New TextBox With {.Size = New Size(60, 60), .Location = New Point((i - 6) * 60, 150)}
Controls.Add(a(i))
End If
Next
End Sub
End Class
本程序在 Visual Basic.net 2010下设计通过
相关文章推荐
- cedit cstatic控件动态生成及字体大小改变
- C# 动态生成窗口中的控件不显示的解决方法
- kindeditor 应用动态生成的控件
- 后台获取前台动态生成控件的值
- Visual C#动态生成控件
- 在.net中利用Web控件Table动态生成表格
- 数据层使用Server对象;动态生成控件多文件上传
- 在asp.net中动态生成web控件1
- 内容选择android控件之Spinner(动态生成下拉内容)
- 网页中动态生成控件的有效控制方案初步(一)
- C#动态生成控件
- 在MFC中创建动态控件的生成与响应
- 动态生成 rtf 并指定给 RichTextBox 控件
- ASP.NET动态加载用户控件的页面生成过程
- ASP.NET动态加载用户控件的页面生成过程
- 动态创建服务器控件,获取HTML输出(用于生成静态文件,简化页面,简化编程等)
- asp.net如何获取页面动态生成的服务器控件
- 动态生成控件
- 动态生成控件
- 在MFC中创建动态控件的生成与响应