1:修改数据源   select  需要显示的列 from  youtable2: 右键选中datagridView->编辑列  添加要显示的列并在右侧设置它的DataPropertyName 为属性名称。

解决方案 »

  1.   

    编辑列的时候通过 HeaderText 设置列标题。
      

  2.   

    datagridView.Columns[c].visible=false;
    循环一下,不显示的列隐藏就好了
    如果数据连后台也用不到,不如查询的时候就不要去查.
      

  3.   


    后台需要查到所有列,只是这个页面不显示那么多而已,
    但是设置DataPropertyName 后报错,如图
      

  4.   

    在SQL语句指定查询的列,或者在GRIDVIEW中手动设置绑定哪几列
      

  5.   

    错误提示  这个requestId列已经存在了。
      

  6.   

    在datatable的基础上创先需要显示内容的视图
    然后绑定视图就可以了
      

  7.   

    在gridview 里面预先设置列
      

  8.   

    使用GridView绑定要显示的字段
     private void Frm_Main_Load(object sender, EventArgs e)
            {
                dgv_Message.DataSource = new List<Fruit>() {//绑定到数据集合
                new Fruit(){Name="海参",Price=30},
                new Fruit(){Name="海马",Price=40},
                new Fruit(){Name="海象",Price=33},
                new Fruit(){Name="海狗",Price=31}};
                dgv_Message.Columns[0].Width = 200;//设置列宽度
                dgv_Message.Columns[1].Width = 170;//设置列宽度
                dgv_Message.Columns[0].DefaultCellStyle.Alignment =//设置对齐方式
                    DataGridViewContentAlignment.MiddleCenter;
            }
        // 使用代码编辑器修改此方法的内容。
                private void InitializeComponent()
            {
                this.dgv_Message = new System.Windows.Forms.DataGridView();
                ((System.ComponentModel.ISupportInitialize)(this.dgv_Message)).BeginInit();
                this.SuspendLayout();
                         this.dgv_Message.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
                this.dgv_Message.Dock = System.Windows.Forms.DockStyle.Fill;
                this.dgv_Message.Location = new System.Drawing.Point(0, 0);
                this.dgv_Message.Name = "dgv_Message";
                this.dgv_Message.RowTemplate.Height = 23;
                this.dgv_Message.Size = new System.Drawing.Size(415, 155);
                this.dgv_Message.TabIndex = 0;
                        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(415, 155);
                this.Controls.Add(this.dgv_Message);
                this.Name = "Frm_Main";
                this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
                this.Text = "对DataGridView控件进行数据绑定";
                this.Load += new System.EventHandler(this.Frm_Main_Load);
                ((System.ComponentModel.ISupportInitialize)(this.dgv_Message)).EndInit();
                this.ResumeLayout(false);        }
      

  9.   

    有多种方法:

    1. 绑定的列之前就选好绑定的那些列.  例 : select * from a  改成  select aid, lastName, fastName from a 
    2. dataGridvie  隐藏不要的列   // DataGridView1的第一列隐藏
    DataGridView1.Columns[0].Visible = false;
    // DataGridView1的第一行隐藏
    DataGridView1.Rows[0].Visible = false;
      

  10.   

    可以在后把你不想显示的列不查询出来,后再把这个结果集给到Datagridview就可以了
      

  11.   

    方法太多了,
    1.你可以在获取数据源的时候把你不想要显示的字段过滤掉。2.数据源全部查出来,在控件上面手动绑定你需要显示的列。3.全部显示在控件上面,然后设置你不需要显示的那几列的Visible属性。
      

  12.   

    dgv 绑定后再隐藏不要的即可.希望能帮助到.