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();
}
}
Erstellt mit dem Designer nur 4 Radios und ein Panel. Auch wenn ich Eigenschaften der VS-Controls abstürzen will, stürzt ich beim Starten des Programms ab. Was kann das Problem sein?Dieser einfache Benutzerkontrollcode stürzt VS2015 ab. Habe keine Ahnung warum
Kann ich eine Eigenschaft nur mit bekommen?
Sie werden Stack Overflow-Ausnahmen in SetRatio und Voltage erstellen. Wenn VS Ihr Steuerelement lädt, wird die Ausführung dieses Codes und des Betriebssystems es herunterfahren. –