http://community.csdn.net/Expert/topic/3927/3927453.xml?temp=.1719782

解决方案 »

  1.   

    this.drp_user.Items.Insert(0,dr);
    你调试看看dr中有数据吗
      

  2.   

    写SelectedIndexChanged事件,然后根据条件用Sql/Oledb....DataReader.Read方法来追加数据项到ComboBox中。
      

  3.   

    写SelectedIndexChanged事件,然后根据条件用Sql/Oledb....DataReader.Read方法来追加数据项到ComboBox中。
      

  4.   

    写SelectedIndexChanged事件,然后根据条件用Sql/Oledb....DataReader.Read方法来追加数据项到ComboBox中。
      

  5.   

    SelectedIndexChanged事件:指定下拉框的绑定内容.
      

  6.   

    使用DataView 来解决这个问题
    //DataRow[] drList = dt.Select("condition...");
    DataView dv = new DataView(dt);
    dv.RowFilter = "condition...";
    comboBox.DataSource = dv;
    comboBox.DisplayMember = "name";
    comboBox.ValueMember = "id";
    ===============
    绑定后,在事件处理程序中取值如下:
    DataRowView drv = (DataRowView)ComboBox1.SelectedItem;
    有了DataRowView就可以得到
    DataRow dr = drv.Row;
    还可以得到DataTable dt = dr.Table;
    DataSet ds = dt.DataSet;
    你想干什么就可以干什么了。
      

  7.   

    Try
                Dim con As String = "server=(local);user id=sa;pwd=;database=pubs"
                Dim objcn As SqlConnection = New SqlConnection(con)
                objcn.Open()
                Dim sqlstr As String = "select * from [user]ssss"
                Dim adpt As New SqlDataAdapter(sqlstr, objcn)
                Dim ds As New DataSet
                adpt.Fill(ds, "TAB")
                '给table添表名
                Dim ts As New DataGridTableStyle
                ts.MappingName = ds.Tables("TAB").TableName
                Dim col1 As New DataGridTextBoxColumn
                With col1
                    .HeaderText = "ID号"
                    .MappingName = "UserID"
                    .ReadOnly = True
                    .NullText = "0"
                    .Width = 100
                End With
                Dim col2 As New DataGridTextBoxColumn
                With col2
                    .HeaderText = " 姓名"
                    .MappingName = "Name"
                    .ReadOnly = True
                    .NullText = "0"
                    .Width = 100
                End With
                Dim col3 As New DataGridTextBoxColumn
                With col3
                    .HeaderText = " 密码"
                    .MappingName = "User_pwd"
                    .ReadOnly = True
                    .NullText = "0"
                    .Width = 100
                End With
                Dim col4 As New DataGridTextBoxColumn
                With col4
                    .HeaderText = " 权限级别"
                    .MappingName = "User_popedom"
                    .ReadOnly = True
                    .NullText = "0"
                    .Width = 100
                End With
                ts.GridColumnStyles.Add(col1)
                ts.GridColumnStyles.Add(col2)
                ts.GridColumnStyles.Add(col3)
                ts.GridColumnStyles.Add(col4)            DataGrid1.TableStyles.Clear()
                DataGrid1.TableStyles.Add(ts)            DataGrid1.DataSource = ds.Tables("TAB")
                'DataGrid1.DataSource = ds.Tables("TAB")
                ComboBox1.DataBindings.Add("Text", ds.Tables("TAB"), "UserID")
                ComboBox1.DataSource = ds.Tables("TAB")
                ComboBox1.ValueMember = "UserID"
                Me.TextBox1.DataBindings.Add("text", ds.Tables("TAB"), "Name")
                Me.TextBox2.DataBindings.Add("text", ds.Tables("TAB"), "User_pwd")
                Me.TextBox3.DataBindings.Add("text", ds.Tables("TAB"), "User_popedom")
                objcn.Close()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
      

  8.   

    给你个简单例子,combox得绑定也类似
      

  9.   

    建立oleDbConnection1到数据库
    private void GetPro()
    {
    OleDbDataReader odr;
    oleDbConnection1.Open();
    odr = oleDbCommand1.ExecuteReader(CommandBehavior.CloseConnection);
    cmbPro.Items.Clear();
    while(odr.Read())
    {
    cmbPro.Items.Add(odr.GetValue(0));
    }
    odr.Close();
    cmbPro.SelectedIndex = 0;
    }
    private void Form1_Load(object sender, System.EventArgs e)
    {
    GetPro();
    }