以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 遍历控件时FileManager 文件管理器的处理 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=75751) |
||||
-- 作者:ljh29206 -- 发布时间:2015/10/14 10:12:00 -- 遍历控件时FileManager 文件管理器的处理
我用遍历控件的方法 查阅 控件
先判断 排除了 .FileManager 这个文件管理器 ,
If TypeOf c Is WinForm.FileManager Then end if
但在遍历控件的过程中,提示找不到 打开,增加 ,删除 等的控件
这些 应该是 FileManager 里面的东东,
如何排除这些东西呢?? |
||||
-- 作者:大红袍 -- 发布时间:2015/10/14 10:19:00 -- 1、贴出你的代码;
2、遍历,是不会遍历控件里面的控件的。 |
||||
-- 作者:ljh29206 -- 发布时间:2015/10/14 10:22:00 -- Dim dr As DataRow For Each f As WinForm.Form In forms If f.Opened = False Then Continue For
dr = DataTables("Language").find("[中文] = \'" & f.text & "\'") If dr IsNot Nothing f.text = dr(getConfigValue("LangC", "英文")) End If dr = DataTables("Language").find("[英文] = \'" & f.text & "\'") If dr IsNot Nothing f.text = dr(getConfigValue("LangC", "中文")) End If
For Each c As Winform.Control In f.Controls If TypeOf c Is Winform.NavBar Then Dim bar As WinForm.NavBar = f.Controls(c.name) For Each nb As WinForm.NavPage In bar.NavPages dr = DataTables("Language").find("[英文] = \'" & nb.ButtonText & "\'") If dr IsNot Nothing nb.Buttontext = dr(getConfigValue("LangC", "中文")) End If dr = DataTables("Language").find("[中文] = \'" & nb.ButtonText & "\'") If dr IsNot Nothing nb.Buttontext = dr(getConfigValue("LangC", "英文")) End If Next
Else If Typeof c Is WinForm.TopicBar Then Dim trv As WinForm.TopicBar = f.Controls(c.name) For Each page As WinForm.TopicPage In trv.Pages For Each nd As WinForm.TopicLink In page.Links dr = DataTables("Language").find("[英文] = \'" & nd.Text & "\'") If dr IsNot Nothing nd.text = dr(getConfigValue("LangC", "中文")) End If dr = DataTables("Language").find("[中文] = \'" & nd.Text & "\'") If dr IsNot Nothing nd.text = dr(getConfigValue("LangC", "英文")) End If Next Next Else If Typeof c Is WinForm.TreeView Then Dim trv As WinForm.TreeView = f.Controls(c.name) For Each nd As WinForm.TreeNode In trv.AllNodes dr = DataTables("Language").find("[英文] = \'" & nd.text & "\'") If dr IsNot Nothing nd.text = dr(getConfigValue("LangC", "中文")) End If dr = DataTables("Language").find("[中文] = \'" & nd.text & "\'") If dr IsNot Nothing nd.text = dr(getConfigValue("LangC", "英文")) End If Next Else If TypeOf c Is WinForm.TabControl Then Dim tc As WinForm.TabControl = f.Controls(c.name) For Each pg As WinForm.TabPage In tc.TabPages dr = DataTables("Language").find("[英文] = \'" & pg.Text & "\'") If dr IsNot Nothing pg.text = dr(getConfigValue("LangC", "中文")) End If dr = DataTables("Language").find("[中文] = \'" & pg.Text & "\'") If dr IsNot Nothing pg.text = dr(getConfigValue("LangC", "英文")) End If Next
Else If TypeOf c Is WinForm.Panel OrElse TypeOf c Is WinForm.picturebox OrElse TypeOf c Is WinForm.Table OrElse TypeOf c Is WinForm.line _ OrElse TypeOf c Is WinForm.WebBrowser OrElse TypeOf c Is WinForm.FileManager OrElse TypeOf c Is WinForm.SplitContainer Then Else Dim ct As String = f.Controls(c.name).text dr = DataTables("Language").find("[英文] = \'" & ct & "\'") If dr IsNot Nothing f.Controls(c.name).text = dr(getConfigValue("LangC", "中文")) End If dr = DataTables("Language").find("[中文] = \'" & ct & "\'") If dr IsNot Nothing f.Controls(c.name).text = dr(getConfigValue("LangC", "英文")) End If End If Next Next
在窗体 出现 有 FileManager 文件管理器的时候 提示 找不到 add open 等 的控件。 |
||||
-- 作者:大红袍 -- 发布时间:2015/10/14 10:27:00 -- 加入msgbox看哪里出错。
做简单例子上来测试 |
||||
-- 作者:ljh29206 -- 发布时间:2015/10/14 10:37:00 -- 老师请看
|
||||
-- 作者:大红袍 -- 发布时间:2015/10/14 10:48:00 -- Dim dr As DataRow For Each f As WinForm.Form In forms If f.Opened = False Then Continue For dr = DataTables("Language").find("[中文] = \'" & f.text & "\'") If dr IsNot Nothing f.text = dr(getConfigValue("LangC", "英文")) End If dr = DataTables("Language").find("[英文] = \'" & f.text & "\'") If dr IsNot Nothing f.text = dr(getConfigValue("LangC", "中文")) End If For Each c As object In f.Controls If TypeOf c Is Winform.NavBar Then Dim bar As WinForm.NavBar = f.Controls(c.name) For Each nb As WinForm.NavPage In bar.NavPages dr = DataTables("Language").find("[英文] = \'" & nb.ButtonText & "\'") If dr IsNot Nothing nb.Buttontext = dr(getConfigValue("LangC", "中文")) End If dr = DataTables("Language").find("[中文] = \'" & nb.ButtonText & "\'") If dr IsNot Nothing nb.Buttontext = dr(getConfigValue("LangC", "英文")) End If Next Else If Typeof c Is WinForm.TopicBar Then Dim trv As WinForm.TopicBar = f.Controls(c.name) For Each page As WinForm.TopicPage In trv.Pages For Each nd As WinForm.TopicLink In page.Links dr = DataTables("Language").find("[英文] = \'" & nd.Text & "\'") If dr IsNot Nothing nd.text = dr(getConfigValue("LangC", "中文")) End If dr = DataTables("Language").find("[中文] = \'" & nd.Text & "\'") If dr IsNot Nothing nd.text = dr(getConfigValue("LangC", "英文")) End If Next Next Else If Typeof c Is WinForm.TreeView Then Dim trv As WinForm.TreeView = f.Controls(c.name) For Each nd As WinForm.TreeNode In trv.AllNodes dr = DataTables("Language").find("[英文] = \'" & nd.text & "\'") If dr IsNot Nothing nd.text = dr(getConfigValue("LangC", "中文")) End If dr = DataTables("Language").find("[中文] = \'" & nd.text & "\'") If dr IsNot Nothing nd.text = dr(getConfigValue("LangC", "英文")) End If Next Else If TypeOf c Is WinForm.TabControl Then Dim tc As WinForm.TabControl = f.Controls(c.name) For Each pg As WinForm.TabPage In tc.TabPages dr = DataTables("Language").find("[英文] = \'" & pg.Text & "\'") If dr IsNot Nothing pg.text = dr(getConfigValue("LangC", "中文")) End If dr = DataTables("Language").find("[中文] = \'" & pg.Text & "\'") If dr IsNot Nothing pg.text = dr(getConfigValue("LangC", "英文")) End If Next Else If TypeOf c Is WinForm.Panel OrElse TypeOf c Is WinForm.picturebox OrElse TypeOf c Is WinForm.Table OrElse TypeOf c Is WinForm.line _ OrElse TypeOf c Is WinForm.WebBrowser OrElse TypeOf c Is WinForm.FileManager OrElse TypeOf c Is WinForm.SplitContainer Then Else Dim ct As String = c.text dr = DataTables("Language").find("[英文] = \'" & ct & "\'") If dr IsNot Nothing c.text = dr(getConfigValue("LangC", "中文")) End If dr = DataTables("Language").find("[中文] = \'" & ct & "\'") If dr IsNot Nothing c.text = dr(getConfigValue("LangC", "英文")) End If End If Next Next |
||||
-- 作者:ljh29206 -- 发布时间:2015/10/14 11:05:00 -- 老师
c.text f.controls(c.name).text
应该是一样的吧!
没搞懂 这2者的区别在哪里! |
||||
-- 作者:大红袍 -- 发布时间:2015/10/14 11:57:00 -- 不一样。foxtable限制了controls直接取某控件。 |