REFERENCES to use CONTROL TYPED VARIABLE . . .
2021-05-13-113528
All --
What REFERENCE or LIBRARY needs to be ADDED or IMPORTED to support the TYPE = CONTROL in the
Dim cControl As Control
statement within the code below?
Private Sub SetControls()
Dim cControl As Control
For Each cControl InMe.Controls
If (TypeOf cControl Is TextBox) Then
cControl.Text = "abc"
End If
Next cControl
End Sub
I believe that a couple of other modifications will be necessary also.
Private Sub SetControls2()
Dim cControl As Control
For Each cControl In MyControl.Controls
If (TypeOf cControl Is TextBox) Then
cControl.Text = "abc"
End If
Next cControl
End Sub
when the FORM for the APP is
MyControl
I am looking for a way to get a list of the CONTROLS within an APP / FORM and then change the .TEXT ATTRIBUTE for most of the CONTROLS based on a TRANSLATION TABLE for MULTIPLE LANGUAGES.
Thank you for your assistance.
-- Matt
0
Best Answers
-
Hi Matt,
This code works for me:Private Sub SetControls2() For Each cControl As System.Windows.Forms.Control In MyControl.Controls If (TypeOf cControl Is System.Windows.Forms.TextBox) Then cControl.Text = "abc" End If Next cControl End Sub
I'm curious about the way you're localizing your app.
I'll check with the Engineering team if there is an easier way to go about it.
Andrew
0 -
Hi Matt,
As you know, Image-Pro is a fully localizable application, currently it can run in 3 languages: English, Japanese and Chinese.
The localization involves multiple steps and uses several external tools:
- the "Localizable" option of the forms and controls is activated: it forces extracting all localizable fields from the forms and user controls to RESX files (for .NET modules)
- then a special tool is used to create resource DLL from these files
- another tool is used to extract localizable strings to a database
- databases for multiple languages are creates and translated accordingly
- new resource DLLs are created and installed to application sub-folders (en/ja/zh-Hans)
These localization DLLs are used when Windows has language settings corresponded to these languages.
These are the steps we use in Image-Pro and they are available for addins created in Visual Studio, but not for the apps that are created in Project Workbench. You can also create addins in Visual Studio.
If you create apps in Project Workbench, you can use other approaches:- the method I recommended (localizing in Designer view), if you use that approach I would recommend to have App.vb file only for UI and all the processing functions in Module.vb, so you can duplicate only UI file for localized versions and use the same processing functions from Module.vb.
- Use run-time localization, as you wanted initially. In that case you have to create a list of all your controls that require localization (you can go through App.designer.vb to find which controls should be localized), you may try to create a function that finds all controls in your your app starting from the main form and recursively going through the list of children of every control (Controls property) (analyzing App.designer.vb can give you idea how controls are related to each other, start from Me.Controls.Add()). and have corresponded localized text for every control, then you can assign localized strings of required language in some initialization function.
0
Answers
that is in the DIALOG EDITOR
-- Matt
The easiest way to translate an app is to create a copy of the app and translate all visible text in Designer view of Project Workbench. You may also need to adjust size of some controls as translated text length can be longer then the English equivalent.
You can also translate text in App.designer.vb file (which you can find in the app's folder), (e.g. replacing Text, Tooltip, Combobox and other English fields by Spanish translations), though you should be careful editing the file to avoid breaking the structure, which could make the app unloadable. Editing in designer view is safer.
Yuri