其中,ComboBox的值是从数据库获取的,代码如下: 
        ds = check.getDatasouce("select * from CustomerInfo", "CustomerInfo");
        this.cbogonghuo.DataSource = ds.Tables["CustomerInfo"].DefaultView;
         this.cbogonghuo.DisplayMember = "CName";            然后我获取ComboBox的值时就出现了问题:System.data.dataRowView       我是通过 this.cbogonghuo.SelectedValue.ToString() 结果出现上面的问题,后来换了一下this.cbogonghuo.SelectedItem.ToString()还是出现同样的结果,      但是,用了this.cbogonghuo.Text.ToString()就对了
      然后我将绑定的内容改了一下:           ds = check.getDatasouce("select * from CustomerInfo", "CustomerInfo");
            this.cbogonghuo.DataSource = ds.Tables["CustomerInfo"].DefaultView;
            this.cbogonghuo.DisplayMember = "CName";
            this.cbogonghuo.ValueMember = "CName";   接着用this.cbogonghuo.SelectedItem.ToString()还是出现同样的错误,而this.cbogonghuo.SelectedValue.ToString() 就对了       虽然问题解决了,但是还是不清楚为什么????不解
 

解决方案 »

  1.   

    关键点就是SelectedValue与SelectedItem区别selecteditem是选中的项,它包括value和text
    selectedvalue是选中项的value两者返回的东西不一样,selectedvalue返回一个string值,selecteditem返回一个ListItem对象
      

  2.   

    怎样取text,为什么SelectedText总是为空.
      

  3.   

    问题已解决,datarowview解决了,再问个小问题,怎样实现预览多个水晶报表,是不是和Grouptree有关,grouptree什么作用。再次感谢各位。
      

  4.   

    没有指明ComboBox绑定的字段名称
    this.comboBox1.DisplayMember = "作为现实文本的字段或属性名";//显示的信息   
    this.comboBox1.ValueMember = "作为值读取的字段或属性名";//Value   
    this.comboBox1.DataSource=数据源;  
    DataRowView drv = ComboBox1.SelectedItem as DataRowView;  
    string sname= drv.Row["colName"].ToString();  
    string svalue= drv.Row["colValue"].ToString();
     
    水晶报表显示多个分组