string str = c_form.mydata.Tables["ccmx2"].Rows[0][23].ToString();
                if (str == radioButton1 .Text )
                {
                    radioButton1.Checked = true;
                    //radioButton1.Enabled = true;
                }
                else if (str == radioButton2.Text )
                {
                    radioButton2.Checked=true;
                    //radioButton1.Enabled = true;                }
                else if (str ==radioButton3 .Text )
                {
                    radioButton3.Checked=true;
                   // radioButton1.Enabled = true;
                }

解决方案 »

  1.   

    晕,忘了问题了,就是那三个radiobutton一个也不会选中,不知道是为什么
      

  2.   

    看了你的代码,我怀疑是第一句的问题!你用调试代码看下str是不是为空,或者是其他值!判断出来之后就知道问题所在了!
    有需要可以联系我啊!大家一起探讨!
    http://www.dianhuaqtq.com/  
    http://www.dianhuaqieting.com/  
    http://www.qingtshouji.com/  
    http://www.qietdianhua.com/
      

  3.   

    str 是否和三个文本都不想等呢,你跟踪一下
      

  4.   

    str取出来是什么呢?
    看跟其他三个radiobutton有没有一样的!
      

  5.   

    str 取出来的是20GP
    radiobutton1.text=20gp
      

  6.   

    大小写不对,你都加上ToUpper就可以了
      

  7.   

    lz在第一个IF那插个断点单步调一下,看str的值是啥啊,要是空或者三个值意外的其他值,肯定就点不出来了。
      

  8.   

    str 取出来的是20GP
    radiobutton1.text=20gp
    大写和小写不可能想等的,需要加上转换为大写或者小写.ToUpper
      

  9.   

    能调试到if 或eles if 语句里面吗?如果不行,那代表字符串不相等,好好检查下,就会知道答案的,代码没错,但是这样写不太美观
      

  10.   

    貌似不能取到radiobutton的值,这是为什么
      

  11.   

    1。把三个放在一个组里面
    2.radioButton1有没有选中事件,看触没触发
      

  12.   

    如下测试可行        private void MainForm_Load(object sender, EventArgs e)
            {
                string str = "radioButton1";
                if (str == radioButton1.Text)
                {
                    radioButton1.Checked = true;
                    //radioButton1.Enabled = true;
                }
                else if (str == radioButton2.Text)
                {
                    radioButton2.Checked = true;
                    //radioButton1.Enabled = true;            }
                else if (str == radioButton3.Text)
                {
                    radioButton3.Checked = true;
                    // radioButton1.Enabled = true;
                }运行结果:
    radioButton1选中,所以推断是你的str取出来的不能正确匹配,调试一下
    注意大小写及空格问题
      

  13.   

    string str = c_form.mydata.Tables["ccmx2"].Rows[0][23].ToString();
     可能是str和3个text值都不相等 你确认下。
      

  14.   

    这种问题,自己调试看能不能进if,进不去当然就说明str判断不相等的。