string sItem = ListBox.SelectedItem.ToString();

解决方案 »

  1.   

    string [Var]=[ControlsName].SelectedItem.ToString();
      

  2.   

    不对,得到的是这个:system.data.datarowview
    我要的是选中的那个值
      

  3.   

    TextBox tb;     tb = (TextBox)(e.Item.Cells[2].Controls[0]);
       categoryName = tb.Text;     tb = (TextBox)(e.Item.Cells[3].Controls[0]);
       categoryDescription = tb.Text;
        dsCategories.CategoriesRow r;
    r = dsCategories1.Categories.FindByCategoryID(int.Parse(key));    r.CategoryName = categoryName;
       r.Description = categoryDescription;
      

  4.   

    不对呀
    我的combobox是和数据库绑定了的
    UPUPUPUPUP
      

  5.   

    好像直接
    string=ComboBox.selectItem就可以取得值了
      

  6.   

    string=ComboBox.selectItem就可以取得值了我是将数据表的数据绑定在combobox上的,用那个无法取得
      

  7.   

    呵呵,我自己解决拉,谢谢大家捧场private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
    DataColumn dc;
    DataTable dt=ds.Tables["项目表"];
    dc =(DataColumn)dt.Columns["项目名称"];
    DataRowView dr;
    dr=(DataRowView)this.comboBox1.SelectedItem;
    string select = dr.Row[dc].ToString();
    MessageBox.Show(select);
    }