【问题标题】:How to localize listview items text?如何本地化列表视图项目文本?
【发布时间】:2012-01-17 20:25:57
【问题描述】:
我在设计时将项目添加到列表视图中,
但项目的文本未添加到相应的 .resx 文件中。
我需要在 Listview 中设置任何属性吗?
我已将底层表单的 Localize 属性设置为“true”
【问题讨论】:
标签:
c#
listview
localization
【解决方案1】:
private void PopulateListView()
{
ListView1.Width = 300;
ListView1.Location = new System.Drawing.Point(10, 50);
// Declare and construct the ColumnHeader objects.
ColumnHeader header1, header2;
header1 = new ColumnHeader();
header2 = new ColumnHeader();
// Set the text, alignment and width for each column header.
header1.Text = "Column1"; //Helper.getlocalStringResource("Xinga.LocalStrings.ColumnHeader.ResourceValue");
header1.Width = 100;
header2.Text = "Column2"; //Helper.getlocalStringResource("Xinga.LocalStrings.ColumnHeader.ResourceValue");
header2.Width = 100;
// Add the headers to the ListView control.
ListView1.Columns.Add(header1);
ListView1.Columns.Add(header2);
ListView1.View = View.Details; //important to see the headers
}
然后可以将 header.Text 本地化...
【解决方案2】:
在表单属性窗口中切换语言。然后更改 ListViewItem 的 Text 属性。
检查您的 resx 中的 Other 部分或在 Xml 编辑器中打开它。