【发布时间】:2008-12-02 17:31:02
【问题描述】:
我正在尝试通过增加字体大小来使 Kiosk 应用程序更易于访问。
主窗体上没有问题。
我在用具有相同消息的小表单替换 MessageBoxes(我认为无法增加字体大小)时遇到问题。
这就是我遇到问题的地方。主窗体无法看到错误窗体及其标签来设置文本。我已尝试在错误表单上为私有标签设置属性,但仍然无法正常工作。
如果能提供任何帮助,我将不胜感激。我一直在尝试应用我在阅读来自各种 C# 源的多个线程时学到的知识。
我注意到了两件奇怪的事情:
- 在 MainForm 中,当我输入 ErrorForm 时,会弹出 Intellisense 建议代码列表,但变量
LblNotCheckedInBecause没有出现在列表中。 - 编译器错误说明了
LBlNotCheckedInBecause.get 语句的一些内容,在我看来它应该引用 set 语句,因为我正在尝试设置该值。
以下是我认为涉及的代码部分:
来自ErrorForm.Designer.cs:
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label lblNotCheckedInBecause;
// property I created to try to be able to change the label
public string LblNotCheckedInBecause
{
get { return this.lblNotCheckedInBecause.Text; }
set { this.lblNotCheckedInBecause.Text = value; }
}
来自MainForm.cs:
// this is what I'm trying to replace
MessageBox.Show("You were not checked in because of the following reasons:" + sErrors);
// this line is causing a compiler error
ErrorForm.LblNotCheckInBecause = "You were not checked in because of the following reasons:" + sErrors;
编译器错误:
错误 1 非静态字段需要对象引用, 方法或属性 'LogisticsKiosk.ErrorForm.LblNotCheckInBecause.get' C:\Documents 和 设置\我的文档\Visual Studio 2005\Projects\LogisticsKiosk\Forms\MainForm.cs 107 17 LogisticsKiosk
【问题讨论】: