解决方案 »

  1.   

     cell.Value 的值要与你绑定ValueMember值一致。
      

  2.   

     cell.Value 的值要与你绑定ValueMember值一致。
    cell.ValueMember绑定的事数据库的字段吗?
      

  3.   

     cell.Value 的值要与你绑定ValueMember值一致。
    cell.ValueMember绑定的事数据库的字段吗?
    是的,比如 你读取数据库数据,读 id与name   设置ValueMember = id 值;DisplayMember=name  这个是显示的值。
      

  4.   

     cell.Value 的值要与你绑定ValueMember值一致。
    cell.ValueMember绑定的事数据库的字段吗?
    是的,比如 你读取数据库数据,读 id与name   设置ValueMember = id 值;DisplayMember=name  这个是显示的值。
    还是不行,显示没有那个字段执行DisplayMember=name  的时候说:没有这个字段。可是我数据库里明明就对应着这个字段
      

  5.   

    执行DisplayMember=name
    name需要替换成你自己的数据库列名啊
    怎么能直接粘进去用呢
      

  6.   

      this.ROLENAME.ValueMember = "Id";
                this.ROLENAME.DisplayMember = "UserRole";我换成了我数据库里面的字段
      

  7.   

    你的datasource绑定的是个datatable吧,
    datatable列名没有修改过吧
    如果修改了,你需要绑定修改后的列名
      

  8.   

    设置Combox控件的默认选项显示值
    public partial class Frm_Main : Form
        {
            public Frm_Main()
            {
                InitializeComponent();
            }
            private void Frm_Main_Load(object sender, EventArgs e)
            {
                cbox_Select.SelectedIndex = 0;//默认选择第一项的值
            }
    }//CodeGo.net/
      partial class Frm_Main
        {
            // <summary>
            // 必需的设计器变量。
            private System.ComponentModel.IContainer components = null;
            // 清理所有正在使用的资源。
               // <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }  // Windows 窗体设计器生成的代码
            // 设计器支持所需的方法 - 不要
            // 使用代码编辑器修改此方法的内容。
                private void InitializeComponent()
            {
                this.cbox_Select = new System.Windows.Forms.ComboBox();
                this.label1 = new System.Windows.Forms.Label();
                this.SuspendLayout();
                this.cbox_Select.FormattingEnabled = true;
                this.cbox_Select.Items.AddRange(new object[] {
                "第一项",
                "第二项",
                "第3项",
                "第4项",
                "第5项",
                "第6项"});
                this.cbox_Select.Location = new System.Drawing.Point(170, 39);
                this.cbox_Select.Name = "cbox_Select";
                this.cbox_Select.Size = new System.Drawing.Size(121, 20);
                this.cbox_Select.TabIndex = 0;
                this.label1.AutoSize = true;
                this.label1.Location = new System.Drawing.Point(63, 42);
                this.label1.Name = "label1";
                this.label1.Size = new System.Drawing.Size(101, 12);
                this.label1.TabIndex = 1;
                this.label1.Text = "默认选择第一项:";
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(355, 93);
                this.Controls.Add(this.label1);
                this.Controls.Add(this.cbox_Select);
                this.Name = "Frm_Main";
                this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
                this.Text = "设置ComboBox控件的默认选项为第一项";
                this.Load += new System.EventHandler(this.Frm_Main_Load);
                this.ResumeLayout(false);
                this.PerformLayout();        }
            private System.Windows.Forms.ComboBox cbox_Select;
            private System.Windows.Forms.Label label1;
        }
      

  9.   

    建议 自己 绘制 combobox 控件 到 dgv 上
    因为 用 dgv 自带 的combobox 是绑定数据源的 很容易出错
    dgv添加combobox
      

  10.   

    应该分别设置ValueMember 和DisplayMember,cellvalue是DG的不是combox的。