Button1.Name = cbName
Button2.Name = pickName
我怎样才能做到这一点?被替换为Button1.Name
将被命名为Button2
(pickName)Button2
并将被命名为 Button1 (cbName)
但为了不告诉我它已经存在Form中的控制元件。
Button1.Name = Button1.Name.Replace("cb", "pick")
也就是说,在我执行订单后,我希望有
Button1.Name = pickName
Button2.Name = cbName
uj5u.com热心网友回复:
问题不清楚:你只是想换个名字吗?在这种情况下:
'Original names
Button1.Name = "cbName"
Button2.Name = "pickName"
Console.WriteLine("Case A: {0}, {1}", {Button1.Name, Button2.Name})
'Name swap
Dim tmp As String = Button1.Name
Button1.Name = Button2.Name
Button2.Name = tmp
Console.WriteLine("Case B: {0}, {1}", {Button1.Name, Button2.Name})
输出:
0 评论