一般我在vb中将控件设成数组,但在.net中不知道怎样实现?
请高手帮忙!
9 个解决方案
#1
For Each T As TextBox In Me.Controls
T.Text = ""
Next
将所有的 TextBox 清空。
T.Text = ""
Next
将所有的 TextBox 清空。
#2
如果有别的容器的话,还要考虑。
下午给你说,要吃饭了
下午给你说,要吃饭了
#3
同意楼上的.
Dim Obj As Object
For Each t In Me.Controls
If TypeOf (Obj ) Is TextBox Orelse ..... Then
obj.text=""
End If
Next
Dim Obj As Object
For Each t In Me.Controls
If TypeOf (Obj ) Is TextBox Orelse ..... Then
obj.text=""
End If
Next
#4
用递归家晚绑定。
sub clearitems(ctrl)
try
ctrl.text=""
catch ex as exception
end try
dim c as control
for each c in ctrl.controls
clearitems(c)
next
end sub
sub clearitems(ctrl)
try
ctrl.text=""
catch ex as exception
end try
dim c as control
for each c in ctrl.controls
clearitems(c)
next
end sub
#5
学习,UP
#6
如果有很多控件又是放在另一个容器里呢,比如GROUPBOX,而GROUPBOX放在FORM上
#7
Private Function CleaText(ByVal Ct As Object)
’用这个函数可以容器里的改掉,Label 再加上
For Each T As Object In Ct.controls
If TypeOf T Is TextBox Then T.text = "找到了"
If TypeOf T Is Label Then T.text = "找到了"
CleaText(T)
Next
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'调用的时候须传最低层的容器过去
CleaText(Me)
End Sub
’用这个函数可以容器里的改掉,Label 再加上
For Each T As Object In Ct.controls
If TypeOf T Is TextBox Then T.text = "找到了"
If TypeOf T Is Label Then T.text = "找到了"
CleaText(T)
Next
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'调用的时候须传最低层的容器过去
CleaText(Me)
End Sub
#8
可以用Form上面的控件不都有个textIndex(还是indexText,记得不是清楚了),根据这个来个循环可以么?我只是说出我的想法,对不对别拿西红柿和鸡蛋砸我,呵呵
#9
分太低
加.....
加.....
#1
For Each T As TextBox In Me.Controls
T.Text = ""
Next
将所有的 TextBox 清空。
T.Text = ""
Next
将所有的 TextBox 清空。
#2
如果有别的容器的话,还要考虑。
下午给你说,要吃饭了
下午给你说,要吃饭了
#3
同意楼上的.
Dim Obj As Object
For Each t In Me.Controls
If TypeOf (Obj ) Is TextBox Orelse ..... Then
obj.text=""
End If
Next
Dim Obj As Object
For Each t In Me.Controls
If TypeOf (Obj ) Is TextBox Orelse ..... Then
obj.text=""
End If
Next
#4
用递归家晚绑定。
sub clearitems(ctrl)
try
ctrl.text=""
catch ex as exception
end try
dim c as control
for each c in ctrl.controls
clearitems(c)
next
end sub
sub clearitems(ctrl)
try
ctrl.text=""
catch ex as exception
end try
dim c as control
for each c in ctrl.controls
clearitems(c)
next
end sub
#5
学习,UP
#6
如果有很多控件又是放在另一个容器里呢,比如GROUPBOX,而GROUPBOX放在FORM上
#7
Private Function CleaText(ByVal Ct As Object)
’用这个函数可以容器里的改掉,Label 再加上
For Each T As Object In Ct.controls
If TypeOf T Is TextBox Then T.text = "找到了"
If TypeOf T Is Label Then T.text = "找到了"
CleaText(T)
Next
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'调用的时候须传最低层的容器过去
CleaText(Me)
End Sub
’用这个函数可以容器里的改掉,Label 再加上
For Each T As Object In Ct.controls
If TypeOf T Is TextBox Then T.text = "找到了"
If TypeOf T Is Label Then T.text = "找到了"
CleaText(T)
Next
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'调用的时候须传最低层的容器过去
CleaText(Me)
End Sub
#8
可以用Form上面的控件不都有个textIndex(还是indexText,记得不是清楚了),根据这个来个循环可以么?我只是说出我的想法,对不对别拿西红柿和鸡蛋砸我,呵呵
#9
分太低
加.....
加.....