如何防止Winforms Label从资源文件中获取其文本?

问题描述 投票:0回答:1

我有一个相当简单的表单,带有一些静态控件。由于某种原因,其中一个标签正在从 .resx 资源文件中检索其

.Text
值。我并没有故意做任何事情来导致这种情况。表单的
InitializeComponent()
将其作为第一行:

Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form_WingInertiaListPrompt))

其中

Form_WingInertiaListPrompt
是表单的名称。再往下,有问题的标签有这样一行:

Me.Label1.Text = resources.GetString("Label1.Text")

.resx 资源文件包含在运行时分配给

.Text
属性的数据:

  <data name="Label1.Text" xml:space="preserve">
    <value>New Select Critical Wing Loads data found. Would you like to automatically generate Wing Inertia cases for the critical wing cases?

This will automatically populate the Case Num, Nz, and Nx fields for each load case.</value>
  </data>

无论我在设计器中的

.Text
属性中输入什么内容,都会在运行时被 .resx 内容覆盖。

其他背景

有问题的表格是我在同一个项目中使用Abdellah OUMGHAR 在这篇文章中的回答制作的类似表格的副本。我想要更改的新表单中的 Label.Text 始终默认为我复制的原始表单中的值。该 Form 正在执行相同的操作,从其自己的 .resx 文件中检索值。我不知道那是怎么发生的。在每个表单上,只有一个标签具有这种行为,所有其他标签都显示我在设计器界面中分配给它们的值。

我尝试卸载解决方案并手动编辑设计器文件以删除

Dim resource...
行,并从 .resx 文件中删除
<data>
标签及其所有内容。当我加载解决方案时,我可以更新设计器中的文本,但是当我运行程序时,所有手动编辑都会在运行时撤消,并显示原始 .resx 值。

vb.net winforms resource-files
1个回答
0
投票

我刚刚做了一个实验,看起来字符串的大小决定了该字符串是否在

.resx
文件中。

尝试让您的

.Text
值变得非常短。

© www.soinside.com 2019 - 2024. All rights reserved.