How to reference DataGridViewColumn.HeaderText manually in resource files?

For transactional purposes, I have created resource files that replace the text property of my winforms components.

However, I can't seem to correctly reference my DataGridViewColumn.HeaderText property manually in the resource file; but I can change its HeaderText property in code but not in the resource file (it works for other components ...)

I've also tried:

DataGridViewColumn.HeaderText = "test1";
DataGridViewColumn.HeaderCell.Value = "test2";
DataGridView.Columns[1].HeaderText = "test3";

      

The code works when called, but not when I put it in the resource file.

+3


source to share


1 answer


If you are using satellite assemblies to store localized text, you can do something like this:

//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

is the key for the text you are trying to localize. TestSatelliteAssembly

- the name of your satellite assembly.

You can read more about satellite assemblies in my blog here .

+2


source







All Articles