Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click
成都創(chuàng)新互聯(lián)公司自2013年創(chuàng)立以來,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目做網(wǎng)站、成都網(wǎng)站建設(shè)網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元西烏珠穆沁做網(wǎng)站,已為上家服務(wù),為西烏珠穆沁各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18982081108
Dim?myAssembly?As?System.Reflection.Assembly?=?System.Reflection.Assembly.GetExecutingAssembly()
Dim?TheTypes?As?Type()?=?myAssembly.GetTypes()
Dim?myType?As?Type
For?Each?myType?In?TheTypes
If?myType.BaseType.ToString?=?"System.Windows.Forms.Form"?Then
ListBox1.Items.Add(myType.Name)
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的單元格命名規(guī)則不一樣,這里的 Item(j, i) 中,列號(hào) j 在前,行號(hào) i 在后。
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
這段代碼可行,但不能遍歷菜單和工具欄,要按需要修改
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
因?yàn)閠extbox在窗體里的panel里,你只遍歷窗體的控件是不夠的。
For Each i As System.Diagnostics.Process In System.Diagnostics.Process.GetProcesses
Next
可以的,需要判斷控件類型并做一下類型轉(zhuǎn)換。
For Each c As Control In Me.Controls
If TypeOf(c) Is TextBox Then
Dim t As TextBox = CType(c ,TextBox)
'調(diào)用t的方法即可
End If
Next