且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用vb.net更改Windows应用程序中窗体上存在的所有控件的语言

更新时间:2023-11-30 15:21:52

我从来没有这样做,但我相信这正是资源文件应该做的事情。基本理论是将所有控制文本转换为字符串资源,为每个控件文本提供唯一标签,并确保代码使用这些标签而不是静态字符串。使用相同的标签创建另一个资源文件,然后您可以互换一个。根据需要制作尽可能多的资源文件。



这项技术称为本地化。它非常简单,但可以有很多移动部件,而不仅仅是作为快速解决方案。搜索.net本地化应该可以为您提供所需的所有信息。通常的做法是将资源文件保存为动态链接库;在应用程序运行时进行热交换可能会非常棘手。
I've never had to do this, but I believe this is exactly what resource files are supposed to do. The basic theory is to turn all of your control text into string resources, give each one a unique label, and make sure your code uses those labels rather than static strings. Create another resource file using the same labels, and then you can swap one for another. Make as many resource files as you need to support.

The technology is called localization. It is pretty straightforward, but there can be a lot of moving parts, more than can be addressed as a quick answer. A search for ".net localization" should give you all the information you need. The usual practice is to save the resource files as dynamic link libraries; hot-swapping those while the application is running is probably going to be very tricky.