我可以同时更改多个控件的属性吗? [英] Can I change more than one control's properties at the same time?

查看:78
本文介绍了我可以同时更改多个控件的属性吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用一些循环来同时更改一系列控件的属性吗?


例如。我有textbox1,textbox2,textbox3,......


如果我想要textbox1.text =" 1",textbox2.text =" 2",textbox3.text =" 3......


我可以用一些循环方法来做这个吗?

Can I use some loop to change a series of control''s properties at same time?

for example. I have textbox1, textbox2, textbox3, ...

If I want textbox1.text = "1", textbox2.text="2", textbox3.text="3"......

Can I use some loop method to do this?

推荐答案

嗨Mike,
Hi Mike,
我可以使用一些循环在相同的
时间更改一系列控件的属性吗?例如。我有textbox1,textbox2,textbox3,......
如果我想要textbox1.text =" 1",textbox2.text =" 2",textbox3.text =" 3" ......
我可以使用一些循环方法来做这个吗?
Can I use some loop to change a series of control''s properties at same time? for example. I have textbox1, textbox2, textbox3, ...
If I want textbox1.text = "1", textbox2.text="2", textbox3.text="3"......
Can I use some loop method to do this?




如果它是一个窗口形式,控件直接在页面上你可以

使用这个

(观看错别字我在这里打字,但它非常简单,所以我不指望它们)


\\\\ \\ / $
对于每个ctr作为me.controls中的控件

如果typeof ctr是Textbox那么

ctr.text = ctr.name.substring( 7)

结束如果

next


这是因为文字是来自对照的比例。

如果你确实想改变行,比你必须写的好

\\\

directcast(ctr,textbox).lines = ctr。等等

///


我希望这有帮助吗?


Cor


使用以下:


Dim obj As Object


Dim i As整数


For Each obj In Me.Controls


for i = 1 to 3


如果obj.name =" textbox" &安培;我然后


obj.text = i


结束如果


下一页


下一页


Vikram


" Mike Chan" < ia*@mikechan.net>在留言中写道

新闻:O5 ************** @ tk2msftngp13.phx.gbl ...
Use following:

Dim obj As Object

Dim i As Integer

For Each obj In Me.Controls

For i = 1 To 3

If obj.name = "textbox" & i Then

obj.text = i

End If

Next

Next

Vikram

"Mike Chan" <ia*@mikechan.net> wrote in message
news:O5**************@tk2msftngp13.phx.gbl...
我可以使用一些循环例如,在相同的
时间更改一系列控件的属性?
。我有textbox1,textbox2,textbox3,...

如果我想要textbox1.text =" 1",textbox2.text =" 2",textbox3.text =" 3" .. ....

我可以使用一些循环方法来执行此操作吗?
Can I use some loop to change a series of control''s properties at same time?
for example. I have textbox1, textbox2, textbox3, ...

If I want textbox1.text = "1", textbox2.text="2", textbox3.text="3"......

Can I use some loop method to do this?



*" Mike Chan" ; < ia*@mikechan.net> scripsit:
* "Mike Chan" <ia*@mikechan.net> scripsit:
我可以使用一些循环来同时更改一系列控件的属性吗?

例如。我有textbox1,textbox2,textbox3,...

如果我想要textbox1.text =" 1",textbox2.text =" 2",textbox3.text =" 3" .. ....

我可以用一些循环方法来做这个吗?
Can I use some loop to change a series of control''s properties at same time?

for example. I have textbox1, textbox2, textbox3, ...

If I want textbox1.text = "1", textbox2.text="2", textbox3.text="3"......

Can I use some loop method to do this?




又快又脏:


\\\

Dim t()As TextBox = {TextBox1,TextBox2,...}

Dim i As Integer

For i = 0 to t.Length - 1

t(i).Text =(i + 1).ToString()

Next i

///


-

Herfried K. Wagner [MVP]

< http:/ /www.mvps.org/dotnet>



Quick and dirty:

\\\
Dim t() As TextBox = {TextBox1, TextBox2, ...}
Dim i As Integer
For i = 0 to t.Length - 1
t(i).Text = (i + 1).ToString()
Next i
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>


这篇关于我可以同时更改多个控件的属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆