符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
可以的,需要判断控件类型并做一下类型转换。
10年积累的成都做网站、网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站策划后付款的网站建设流程,更有天峨免费网站建设让你可以放心的选择与我们合作。
For Each c As Control In Me.Controls
If TypeOf(c) Is TextBox Then
Dim t As TextBox = CType(c ,TextBox)
'调用t的方法即可
End If
Next
For Each ctl As Control In Me.Controls If TryCast(ctl, TextBox) Nothing Then Dim txt As TextBox = TryCast(ctl, TextBox) txt.Text = "" End If
Public Sub ReSetText(Control ctrl)
Dim ct As Control
For Each ct In ctrl.Controls
Try
For Each ct2 As Control In ct.Controls
ReSetText(ct2)
Next
Catch
End Try
If (TypeOf ct Is TextBox) Then
ct.Text = ""
ElseIf (TypeOf ct Is ComboBox) Then
Dim cb As System.Windows.Forms.ComboBox = DirectCast(ct, System.Windows.Forms.ComboBox)
cb.SelectedIndex = -1
End If
Next
End Sub
因为textbox在窗体里的panel里,你只遍历窗体的控件是不够的。
c# 用程序转的,也不知道对不对。你看看有没有帮助 ,这是遍历所有控件,还有一个办法就是重载form的消息处理函数应该也是可以的。
STAThread _
Public Shared Sub Main(args As String())
Dim button = New Button()
button.Text = "我是按钮"
button.Dock = DockStyle.Fill
Dim form = New Form()
form.Controls.Add(button)
CapturehMouseClickEvent(form)
form.ShowDialog()
End Sub
Private Shared Sub CapturehMouseClickEvent(control As Control)
AddHandler control.Click, AddressOf ControlOnClick
For Each subControl As Control In control.Controls
CapturehMouseClickEvent(subControl)
Next
End Sub
Private Shared Sub ControlOnClick(sender As Object, eventArgs As EventArgs)
Debug.WriteLine("控制被单击")
End Sub
Public Sub GetAllControls(ByVal InContainer As Control, ByRef RecieveList As ListBox)
For i As Integer = 0 To InContainer.Controls.Count - 1
If InContainer.Controls.Item(i).Text "" Then
GetList.Items.Add(InContainer.Controls.Item(i).Text vbCrLf)
End If
If InContainer.Controls.Item(i).Controls.Count 0 Then
GetAllControls(InContainer.Controls.Item(i), GetList)
End If
Next
End Sub
这段代码可行,但不能遍历菜单和工具栏,要按需要修改
遍历的例子:
Dim i, j As Integer
For i = 0 To DataGridView1.RowCount - 1
For j = 0 To DataGridView1.ColumnCount - 1
MsgBox(DataGridView1.Item(j, i).Value)
Next
Next
注意:与Excel的单元格命名规则不一样,这里的 Item(j, i) 中,列号 j 在前,行号 i 在后。