应该是你的代码问题吧?不要随便就认为MS的有BUG。把你的代码贴出来后通知我。

解决方案 »

  1.   

    if(write.IFreadOnly.ReadOnlyTF ==false)
    {
    #region  Write

    switch (this.txt_state.Text.Trim())
    {
    case  "完成":
    this.txt_needdate.Enabled=false; 
    this.txt_Re.Enabled=false;
    this.yang_Combo1.Enabled=false;
    this.combox_org.Enabled=false;
    this.txt_ReceiveArea.Enabled=false;
    this.txt_ReceiveArea.Enabled=false;
    this.toolBar1.Buttons[0].Enabled=true;
    this.toolBar1.Buttons[1].Enabled=true;
    this.toolBar1.Buttons[2].Enabled=false;
    this.toolBar1.Buttons[3].Enabled=true;
    this.toolBar1.Buttons[4].Enabled=true;
    this.toolBar1.Buttons[5].Enabled=true;
    this.toolBar1.Buttons[6].Enabled=false;
    this.toolBar1.Buttons[7].Enabled=true;
    this.lab_SendDate.Visible=true; 
    this.btn_SendDate.Visible=true;
    this.dtTime_Date.Visible=true;
    this.dtTime_Time.Visible=true; 
    this.txt_Money.Visible=false;
    this.comboBox_NeedDeductTF.Enabled=false;
    break;
    case  "录入":
    this.txt_needdate.Enabled=true; 
    this.txt_Re.Enabled=true;
    this.yang_Combo1.Enabled=true;
    this.comboBox1.Enabled=true;
    this.combox_org.Enabled=false;
    this.combox_agentName.Enabled=false;
    this.txt_ReceiveArea.Enabled=true;
    this.toolBar1.Buttons[0].Enabled=true;
    this.toolBar1.Buttons[1].Enabled=true;
    this.toolBar1.Buttons[2].Enabled=true;
    this.toolBar1.Buttons[3].Enabled=false;
    this.toolBar1.Buttons[4].Enabled=true;
    this.toolBar1.Buttons[5].Enabled=true;
    this.toolBar1.Buttons[6].Enabled=true;
    this.toolBar1.Buttons[7].Enabled=false;
    this.lab_SendDate.Visible=false; 
    this.btn_SendDate.Visible=false;
    this.dtTime_Date.Visible=false;
    this.dtTime_Time.Visible=false;
    this.txt_Money.Visible=false;
    this.comboBox_NeedDeductTF.Enabled=true;
    if(ChangeBFSave==false)
    {
    this.toolBar1.Buttons[6].Enabled=true;
    }
    else
    {
    this.toolBar1.Buttons[6].Enabled=false;
    }
    break;
    case  "取消":
    this.txt_needdate.Enabled=false;
    this.txt_Re.Enabled=false;
    this.txt_ReceiveArea.Enabled=false;
    this.yang_Combo1.Enabled=false;
    this.txt_ReceiveArea.Enabled=false;
    this.toolBar1.Buttons[0].Enabled=true;
    this.toolBar1.Buttons[1].Enabled=true;
    this.toolBar1.Buttons[2].Enabled=false;
    this.toolBar1.Buttons[3].Enabled=false;
    this.toolBar1.Buttons[4].Enabled=true;
    this.toolBar1.Buttons[5].Enabled=true;
    this.toolBar1.Buttons[6].Enabled=false;
    this.toolBar1.Buttons[7].Enabled=false;
    this.lab_SendDate.Visible=false; 
    this.btn_SendDate.Visible=false;
    this.dtTime_Date.Visible=false;
    this.dtTime_Time.Visible=false;
    this.txt_Money.Visible=false;
    this.comboBox_NeedDeductTF.Enabled=false;
    break;
      

  2.   

    case  "":
    this.txt_needdate.Enabled=true; 
    this.txt_Re.Enabled=true;
    this.yang_Combo1.Enabled=true;
    this.comboBox1.Enabled=true;
    this.combox_agentName.Enabled=true;
    this.combox_org.Enabled=true;
    this.lab_SendDate.Visible=false; 
    this.btn_SendDate.Visible=false;
    this.txt_ReceiveArea.Enabled=true;
    this.toolBar1.Buttons[0].Enabled=false;
    this.toolBar1.Buttons[1].Enabled=true;
    this.toolBar1.Buttons[2].Enabled=true;
    this.toolBar1.Buttons[3].Enabled=false;
    this.toolBar1.Buttons[4].Enabled=true;
    this.toolBar1.Buttons[5].Enabled=false;
    this.toolBar1.Buttons[6].Enabled=false;
    this.toolBar1.Buttons[7].Enabled=false;
    this.dtTime_Date.Visible=false;
    this.dtTime_Time.Visible=false;
    this.txt_Money.Visible=false;
    this.comboBox_NeedDeductTF.Enabled=true;
    break;
    case  "已发货":
    this.txt_needdate.Enabled=false; 
    this.txt_Re.Enabled=false;
    this.yang_Combo1.Enabled=false;
    this.combox_org.Enabled=false;
    this.txt_ReceiveArea.Enabled=false;
    this.dtTime_Date.Visible=true;
    this.dtTime_Time.Visible=true;
    this.dtTime_Date.Enabled=false;
    this.dtTime_Time.Enabled=false;
    this.lab_SendDate.Visible=true; 
    this.btn_SendDate.Visible=false;
    this.toolBar1.Buttons[0].Enabled=true;
    this.toolBar1.Buttons[1].Enabled=true;
    this.toolBar1.Buttons[2].Enabled=false;
    this.toolBar1.Buttons[3].Enabled=false;
    this.toolBar1.Buttons[4].Enabled=true;
    this.toolBar1.Buttons[5].Enabled=true;
    this.toolBar1.Buttons[6].Enabled=false;
    this.toolBar1.Buttons[7].Enabled=true;
    this.btn_Deduct.Visible=true;
    this.btn_Deduct.Enabled=true;
    this.txt_Money.Visible=true;
    this.comboBox_NeedDeductTF.Enabled=false;   
    break;
    case  "已扣款":
    this.txt_needdate.Enabled=false; 
    this.txt_Re.Enabled=false;
    this.yang_Combo1.Enabled=false;
    this.combox_org.Enabled=false;
    this.txt_ReceiveArea.Enabled=false;
    this.dtTime_Date.Visible=true;
    this.dtTime_Time.Visible=true;
    this.dtTime_Date.Enabled=false;
    this.dtTime_Time.Enabled=false;
    this.lab_SendDate.Visible=true; 
    this.btn_SendDate.Visible=false;
    this.toolBar1.Buttons[0].Enabled=true;
    this.toolBar1.Buttons[1].Enabled=true;
    this.toolBar1.Buttons[2].Enabled=false;
    this.toolBar1.Buttons[3].Enabled=true;
    this.toolBar1.Buttons[4].Enabled=true;
    this.toolBar1.Buttons[5].Enabled=true;
    this.toolBar1.Buttons[6].Enabled=false;
    this.toolBar1.Buttons[7].Enabled=false;
    this.txt_Money.ReadOnly=true;
    this.btn_Deduct.Visible=true;
    this.btn_Deduct.Enabled=false;
    this.txt_Money.Visible=true;
    this.comboBox_NeedDeductTF.Enabled=false;
    break;    
      

  3.   

    if else 语句的这情况我也遇见过
    后来该代码了事
      

  4.   

    你的代码好象没有贴完。但从你的代码来看是没有什么问题的。switch语句遇到break后是终止整个该语句的执行的,应该是不会出现什么从这个break跳到下个break的情况。出现你这样的问题是否你的switch后的参数有问题?比如你传入了一个在switch语句的case条件中没有吻合的字符串?对于这种意外,建议不要省略了default子句。
      

  5.   

    我后来也加上了default 语句,还是这样
      

  6.   

    题外话:
    你最好将这些设置Enabled的语句写成一个函数来调用,增加代码的复用性和可读性
      

  7.   

    FAINT,楼主,连大括弧不不想写,你的语法有问题,重头开始学!
    switch(param)
    {
      case expr1:
      { 
        ......
        if(ex1)
          ..
        else
          ...  
        break;  //这个必不可少
      }
      case expr2:
      {
        ...
        break;
      }
      default:   
        break;
    }
      

  8.   

    啊,晕~我真的不知道用 switch 还要加括号啊~~
      

  9.   

    qianli918(千里马) 老兄说的错误,呵呵。。我是不会犯滴~~
    再试试
      

  10.   

    受不了了!
    加了大括号,加了default,
    一个case 的break 后,又跑到default 的break 下去了!
      

  11.   

    那个是编译器优化的结果,实际上任何一个case的break以及default的break都是跳出switch,跳到哪一个break又有什么本质上的问题呢?
      

  12.   

    TO LA003 :
    关于语法,其实可以用msdn很快的找到大部分的,建议你一定看一下,必须+{}