以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]代码合并 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=57423) |
-- 作者:yifan3429 -- 发布时间:2014/9/24 15:55:00 -- [求助]代码合并 For Each i As Integer = 1 To 13 Dim sp As WinForm.SplitContainer = e.Form.Controls("SplitContainer" & i ) sp.Panel1.Collapsed = True Next 上面的代码想替代下面的代码 会报错 哪里错了 \'Dim sp As WinForm.SplitContainer = e.Form.Controls("SplitContainer1") \'sp.Panel1.Collapsed = True \' \'Dim s1p As WinForm.SplitContainer = e.Form.Controls("SplitContainer7") \'s1p.Panel2.Collapsed = True \' \'Dim s4p As WinForm.SplitContainer = e.Form.Controls("SplitContainer8") \'s4p.Panel2.Collapsed = True \' \'Dim s2p As WinForm.SplitContainer = e.Form.Controls("SplitContainer10") \'s2p.Panel1.Collapsed = True \' \'Dim s3p As WinForm.SplitContainer = e.Form.Controls("SplitContainer13") \'s3p.Panel1.Collapsed = True
|
-- 作者:Bin -- 发布时间:2014/9/24 15:58:00 -- 如果你没有 2 3 4 5 6 9 11 12 那就无法正常获取控件,自然就报错了啊. |
-- 作者:yifan3429 -- 发布时间:2014/9/24 15:59:00 -- 那这种情况 怎么办呢 |
-- 作者:Bin -- 发布时间:2014/9/24 15:59:00 -- 最简单的办法调整你控件的名称为连续的 数字 |
-- 作者:有点甜 -- 发布时间:2014/9/24 15:59:00 -- Dim sp1() As Integer = {1,10,13} Dim sp2() As Integer = {7,8} For Each i As Integer In sp1 Dim sp As WinForm.SplitContainer = e.Form.Controls("SplitContainer" & i) sp.Panel1.Collapsed = True Next For Each i As Integer In sp2 Dim sp As WinForm.SplitContainer = e.Form.Controls("SplitContainer" & i) sp.Panel2.Collapsed = True Next |
-- 作者:yifan3429 -- 发布时间:2014/9/24 16:40:00 -- 谢谢甜老师 |
-- 作者:yifan3429 -- 发布时间:2014/9/25 11:17:00 -- -
[此贴子已经被作者于2014-9-25 11:26:26编辑过]
|