因此,我对软件中的错误不屑一顾。
我有此代码,我在软件中使用了2次,其他类似功能(名称不同)正常运行。但是这个倒是...
我的意思是:它不是在groupbox.text包含“ INC”时启用控件,而是禁用它们。
有什么想法吗?
`private void Enable_disableSTM()
{
if (STM_groupBox.Text.Contains("INC"))
{
STM_radioButton_appel.Enabled = true;
STM_radioButton_autre.Enabled = true;
STM_radioButton_resolution.Enabled = true;
STM_Textbox_SR.Enabled = true;
STM_textBox_remarque.Enabled = true;
STM_Dropdown_Sendto.Enabled = true;
STM_pictureBox_Boutonenvoyer.Enabled = true;
}
else
{
STM_radioButton_appel.Enabled = false;
STM_radioButton_autre.Enabled = false;
STM_radioButton_resolution.Enabled = false;
STM_Textbox_SR.Enabled = false;
STM_textBox_remarque.Enabled = false;
STM_Dropdown_Sendto.Enabled = false;
STM_pictureBox_Boutonenvoyer.Enabled = false;
}
} `
编辑:
就像我说的那样,在我的软件中,我还有其他功能正常运行。我也尝试将IF更改为STM_Textbox_reademail.Text != ""
,但仍无法正常工作。倒过来了启用不应启用的功能,也禁用。
`if (SQ_TextBox_reademail.Text != "")
{
SQ_radioButton_appel.Enabled = true;
SQ_radioButton_autre.Enabled = true;
SQ_radioButton_resolution.Enabled = true;
SQ_Textbox_SR.Enabled = true;
SQ_textBox_remarque.Enabled = true;
SQ_Dropdown_Sendto.Enabled = true;
SQ_pictureBox_Boutonenvoyer.Enabled = true;
}
else
{
SQ_radioButton_appel.Enabled = false;
SQ_radioButton_autre.Enabled = false;
SQ_radioButton_resolution.Enabled = false;
SQ_Textbox_SR.Enabled = false;
SQ_textBox_remarque.Enabled = false;
SQ_Dropdown_Sendto.Enabled = false;
SQ_pictureBox_Boutonenvoyer.Enabled = false;
} `
编辑2:好的...我想出了一些可行的方法。我现在在另一个地方调用我的函数,它正在运行。为何我仍可以在同一个地方打电话给另一个人还是可行的,但这仍然没有道理。谢谢大家!
答案 0 :(得分:0)
您的问题是,您正在以区分大小写的方式检查字符串中是否包含“ INC”字样,该解决方案正在更改if语句以忽略该大小写将inc字词输入字符串中:
private void Enable_disableSTM()
{
if (STM_groupBox.Text.IndexOf("INC", StringComparison.OrdinalIgnoreCase) >= 0;)
{
STM_radioButton_appel.Enabled = true;
STM_radioButton_autre.Enabled = true;
STM_radioButton_resolution.Enabled = true;
STM_Textbox_SR.Enabled = true;
STM_textBox_remarque.Enabled = true;
STM_Dropdown_Sendto.Enabled = true;
STM_pictureBox_Boutonenvoyer.Enabled = true;
}
else
{
STM_radioButton_appel.Enabled = false;
STM_radioButton_autre.Enabled = false;
STM_radioButton_resolution.Enabled = false;
STM_Textbox_SR.Enabled = false;
STM_textBox_remarque.Enabled = false;
STM_Dropdown_Sendto.Enabled = false;
STM_pictureBox_Boutonenvoyer.Enabled = false;
}
}