【发布时间】:2010-01-30 13:21:54
【问题描述】:
我正在翻译我的 VB.Net 应用程序,我需要遍历表单上的所有控件。使用递归函数,例如
Public Sub TranslateControl(ByVal Ctrl As Control)
For Each ChildCtrl As Control In Ctrl.Controls
ChildCtrl.Text = Translate(ChildCtrl.Text)
If TypeOf ChildCtrl Is Label Then
CType(ChildCtrl, Label).Tag = Translate(CType(ChildCtrl, Label).Tag)
End If
TranslateControl(ChildCtrl)
Next
End Sub
效果很好,但它不包括CommonDialog 对象,例如FolderBrowser 对象。如何访问这些对象?我试过这个
For Each ChildDialog As CommonDialog In Ctrl.Controls
ChildDialog.Tag = Translate(ChildDialog.Tag)
Next
但显然存在继承问题,因为CommonDialog 对象不是controls。
有没有办法让我遍历表单上显示的所有项目?
非常感谢!
CFP
【问题讨论】:
标签: vb.net controls translation winforms common-dialog