c# - Windows 窗体 PropertyView 不可见文本
问题描述
我在 C# 解决方案中有一个弹出窗口,其中有一个 PropertyView 控件...突然之间,属性字段报告了一个不可见的值,但是如果我单击该字段,则该值变得可见。如果我然后单击该字段,则该值再次隐藏...昨天一切都很好今天我从 16.9.0 更新到 Visual Studio 16.9.1...这可能是原因吗?同样在另一台计算机上的已部署解决方案上,这些字段的行为方式相同......但昨天在我的站上一切都很好,我至少一周内没有触摸这些弹出窗口......代码是在 c# 中开发的.Net 5 与 windows 窗体。
namespace LiMA.Manager
{
partial class PlcParametersPopup
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.plcPropertyGrid = new System.Windows.Forms.PropertyGrid();
this.setPlcParamsBtn = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// plcPropertyGrid
//
this.plcPropertyGrid.CommandsBackColor = System.Drawing.SystemColors.ControlDark;
this.plcPropertyGrid.Location = new System.Drawing.Point(2, 2);
this.plcPropertyGrid.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.plcPropertyGrid.Name = "plcPropertyGrid";
this.plcPropertyGrid.PropertySort = System.Windows.Forms.PropertySort.Categorized;
this.plcPropertyGrid.Size = new System.Drawing.Size(379, 710);
this.plcPropertyGrid.TabIndex = 0;
//
// setPlcParamsBtn
//
this.setPlcParamsBtn.FlatAppearance.BorderSize = 0;
this.setPlcParamsBtn.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50)))));
this.setPlcParamsBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.setPlcParamsBtn.Font = new System.Drawing.Font("Calibri Light", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.setPlcParamsBtn.ForeColor = System.Drawing.Color.Gainsboro;
this.setPlcParamsBtn.Location = new System.Drawing.Point(2, 718);
this.setPlcParamsBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.setPlcParamsBtn.Name = "setPlcParamsBtn";
this.setPlcParamsBtn.Size = new System.Drawing.Size(379, 40);
this.setPlcParamsBtn.TabIndex = 1;
this.setPlcParamsBtn.Text = "Set PLC Parameters";
this.setPlcParamsBtn.UseVisualStyleBackColor = true;
this.setPlcParamsBtn.Click += new System.EventHandler(this.setPlcParamsBtn_Click);
//
// PlcParametersPopup
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
this.ClientSize = new System.Drawing.Size(384, 761);
this.Controls.Add(this.setPlcParamsBtn);
this.Controls.Add(this.plcPropertyGrid);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.Name = "PlcParametersPopup";
this.Text = "<PlcName> Parameters";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PropertyGrid plcPropertyGrid;
private System.Windows.Forms.Button setPlcParamsBtn;
}
}
这是我的弹出式设计师课程。
public PlcParametersPopup(PlcSettings plcParameters, MainView main)
{
InitializeComponent();
PlcName = plcParameters.Name;
Text = PlcName + " Parameters";
plcPropertyGrid.SelectedObject = plcParameters;
mainView = main;
}
这是弹出窗口的构造函数,如您所见,我将包含一系列属性字段的类传递给 SelectedObject 字段,如下所示。
namespace LiMA.Parameters
{
public class PlcSettings
{
[Category("Basic Settings"), Description("Name of the PLC"), ReadOnly(true)]
public string Name { get; set; }
[Category("Addressing Settings"), Description("Ip address of the PLC"), ReadOnly(true)]
public string IpAddr { get; set; }
[Category("Addressing Settings"), Description("PLC rack from hw configuration"), ReadOnly(true)]
public int Rack { get; set; }
[Category("Addressing Settings"), Description("PLC slot from hw configuration"), ReadOnly(true)]
public int Slot { get; set; }
[Category("Data Settings"), Description("Datablock number in the PLC"), ReadOnly(true)]
public int DBNumber { get; set; }
[Category("Data Settings"), Description("Byte offset in datablock"), ReadOnly(true)]
public int ByteWatchdogToPLC { get; set; }
[Category("Data Settings"), Description("Byte offset in datablock"), ReadOnly(true)]
public int ByteStringMessage { get; set; }
[Category("Data Settings"), Description("Byte offset in datablock"), ReadOnly(true)]
public int ByteCommands { get; set; }
[Category("Data Settings"), Description("Byte offset in datablock"), ReadOnly(true)]
public int ByteAlarms { get; set; }
[Category("Data Settings"), Description("Byte offset in datablock"), ReadOnly(true)]
public int ByteWarnings { get; set; }
[Category("Data Settings"), Description("Byte offset in datablock"), ReadOnly(true)]
public int ByteOutParams { get; set; }
[Category("Data Settings"), Description("Byte offset in datablock"), ReadOnly(true)]
public int ByteInParams { get; set; }
[Category("Data Settings"), Description("Byte offset in datablock"), ReadOnly(true)]
public int ByteDataProcessor1 { get; set; }
[Category("Data Settings"), Description("Byte offset in datablock"), ReadOnly(true)]
public int ByteDataProcessor2 { get; set; }
}
}
解决方案
推荐阅读
- haskell - Haskell 将非确定性与错误处理相结合
- typescript - 带有部分字段类型的 Typescript 接口
- tensorflow - 是否可以在 Keras 中定义自己的评估函数?
- javascript - Flask - Bootstrap Navbar Dropdown 在子页面上不起作用
- python - 指数拟合和对数线性拟合之间的差异
- python - python:如何将文件夹的完整路径复制到其他文件夹
- ffmpeg - 如何在ffmpeg中结合几个jpeg文件和几个wav文件?
- leaflet - 带有 Sapper SSR 的 Svelte js - 可以为 leaflet.js 提供“窗口”吗?
- reactjs - 如何在 NextJS 中创建轮播?
- java - 如何返回空结果集