【发布时间】:2017-07-01 23:44:02
【问题描述】:
public partial class displayvoltage : UserControl
{
public displayvoltage()
{
InitializeComponent();
if (!this.ratio_1.Checked && !this.ratio_12.Checked && !this.ratio_34.Checked && !this.ratio_14.Checked)
this.ratio_1.Checked = true;
}
public double Ratio
{
get
{
if (this.ratio_1.Checked) return 1.0;
if (this.ratio_1.Checked) return 4.0 / 3.0;
if (this.ratio_1.Checked) return 2.0;
return 4.0;
}
}
public int SetRatio
{
set
{
if (value == 1) this.ratio_1.Checked = true;
if (value == 2) this.ratio_34.Checked = true;
if (value == 3) this.ratio_12.Checked = true;
if (value == 4) this.ratio_14.Checked = true;
SetRatio = value;
}
}
[DefaultValue(0.0)]
public double Voltage
{
get { return Voltage * this.Ratio; }
set { Voltage = value; }
}
private bool DisplayVoltage = false;
private bool Pause = false;
private void ratio_CheckedChanged(object sender, EventArgs e)
{
RadioButton r = (RadioButton)sender;
if (r.Checked) Invalidate();
}
}
由设计师创建,只有 4 个收音机和一个面板。 即使我想显示控件 VS 崩溃的属性,如果我启动程序它也会崩溃。可能是什么问题?
我可以拥有一个只有 get 的属性吗?
【问题讨论】:
-
您将在 SetRatio 和 Voltage 中创建堆栈溢出异常。当 VS 加载您的控件时,它会执行此代码并且操作系统将关闭它。
标签: c# visual-studio-2015 crash