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();
}
}
créé avec le concepteur seulement 4 radios et un panneau. Même si je veux afficher les propriétés du contrôle VS se bloque, si je démarre le programme il se bloque. Quel peut être le problème?Ce code de contrôle utilisateur simple bloque VS2015. Ne sais pas pourquoi
Puis-je avoir une propriété avec seulement obtenir?
Vous allez créer des exceptions de débordement de pile dans SetRatio et Voltage. Lorsque VS charge votre contrôle, l'exécution de ce code et le système d'exploitation vont l'arrêter. –