C# 更改c中的字段属性#
嗨,我有一个类textProgreesBar,它包含C# 更改c中的字段属性#,c#,properties,C#,Properties,嗨,我有一个类textProgreesBar,它包含 public enum ProgressBarDisplayMode { NoText, Percentage, CurrProgress, CustomText, TextAndPercentage, TextAndCurrProgress } 然后 我尝试在单击按钮时将currogress动态更改为百分比 private void button2_Click(object sender,
public enum ProgressBarDisplayMode
{
NoText,
Percentage,
CurrProgress,
CustomText,
TextAndPercentage,
TextAndCurrProgress
}
然后
我尝试在单击按钮时将currogress动态更改为百分比
private void button2_Click(object sender, EventArgs e)
{
this.textProgressBar1.VisualMode = "Percentage";
}
但它退出了CS0029
我可以在单击按钮时更改此属性以及如何更改吗?您需要这样做
this.textProgressBar1.VisualMode = ProgressBarDisplayMode.Percentage;
您可以这样做
this.textProgressBar1.VisualMode=ProgressBarDisplayMode.Percentage
您需要使用枚举值,请尝试:textProgressBar1.VisualMode=ProgressBarDisplayMode.Percentage
insteadAs ProgressBarDisplayMode是其他命名空间this.textProgressBar1.VisualMode=ProgressBarSample.ProgressBarDisplayMode.Percentage;。谢谢您!您可以使用
this.textProgressBar1.VisualMode = ProgressBarDisplayMode.Percentage;