出于事务处理的目的,我创建了资源文件,以替换winforms组件的text属性。
然而,我似乎不能在资源文件中手动引用我的DataGridViewColumn.HeaderText属性;但是我可以在代码中更改它的HeaderText属性,但不能在资源文件中更改它的HeaderText属性(它可以用于其他组件.)
我也试过:
DataGridViewColumn.HeaderText = "test1";
DataGridViewColumn.HeaderCell.Value = "test2";
DataGridView.Columns[1].HeaderText = "test3";代码在调用它时起作用,但当我把它放在资源文件中时,代码就不能工作了。
发布于 2017-07-17 09:24:32
如果使用附属程序集来保留本地化文本,则可以执行以下操作:
//namespacaes to be imported at the top of your code file
using System.Resources;
using System.Reflection;
//source code for your method
ResourceManager resourceManager = new ResourceManager("TestSatelliteAssembly.Resources.LocalizedResources",Assembly.GetExecutingAssembly());
DataGridViewColumn.HeaderText = resourceManager.GetString("lblUserNameText");lblUserNameText是您要本地化的文本的关键。TestSatelliteAssembly是卫星程序集的名称。
您可以在我的博客这里中阅读更多关于卫星程序集的信息。
https://stackoverflow.com/questions/45140170
复制相似问题