这个很简单呀
int  i;if(combbox1.selectitem == "操作员")
    i = 0;
if(combbox1.selectitem == "系统管理员")
    i = 1;然后把i写到数据库对应的字段就可以了

解决方案 »

  1.   

    如果字段非常多的话,做一个类
     class Myclass
     {
        private string name;
        private int id;
        
        public string Name
        {
          get {return name;
    }
       public int Id
      { 
         get{return id;}    public Mycalss(string name,int id)
        {
          this.name = name;
          this.id = id;
    }  public override string ToString()
      {
            return this.name;
      }
    } 然后声明许多这样的实例Mycalss c = new Mycalss("系统管理员",1);
    ..........................然后加进去combbox
    this.combbox.item.add(c);
    .....
    然后取出来Mycalss cc = (Mycalss)this.cobbox.selectitem;
    cc.Id就是你要的东西。
      

  2.   

    定义好CombBox的Items的次序,然后:
     int i;
     
     i=CombBox1.SelectIndex;
     
     switch (i)
    {
      case 0:
         //...
        break;
      case 1:
        //...
       break;
      //...
      default:break;
    }
      

  3.   

    如果类型较多的话,可以考虑用枚举。然后添加一个tostring函数。
      

  4.   

    上面的方法其实是把汉字和数字放在了一个自定义的类里面,建立对应的关系。
    然后combbox的item其实是一个object类型的,你可以加任何东西到里面,而combbox显示给你的就是这个object.ToString()。所以上面的类中要过载ToString()方法。取出combbox的选中的item,因为是一个object类型的,所以要做一个类型转换,转换成自定义类型的,然后取出他的属性Id就可以了。
      

  5.   

    //给你个例子
    SqlConnection conn = new SqlConnection("server=pany;database=exoaextend;uid=sa;pwd=123");
    SqlDataAdapter cmd = new SqlDataAdapter("select * from exoaunits", conn);
    DataSet ds = new DataSet();
    cmd.Fill(ds, "units");
    //combobox绑定数据源
    comboBox1.DataSource = ds.Tables["units"].DefaultView;
    comboBox1.ValueMember = "UnitID"; //指定ID字段
    comboBox1.DisplayMember = "UnitName";//指定显示字段
    conn.Close();
    //取得ID值
     MessageBox.Show(comboBox1.SelectedValue.ToString());