How to Bind specific Columns of a datatable to a DataGridView?

前端 未结 6 520
眼角桃花
眼角桃花 2020-12-09 11:43

My DataTable has three columns fetched from a database, while I need to bind only two columns of it to a DataGridView. Can you please help me with

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-09 12:08

    Bind DataTable to DataGridView after that hide the column you don't want.

    dataGridView1.DataSource = datatable;
    dataGridView1.Columns["ColumnName"].Visible = false;
    

提交回复
热议问题