How to hide a columns in a DataGridview [Resolved]

Posted by Amulya under C# on 8/18/2013 | Points: 10 | Views : 1992 | Status : [Member] | Replies : 3
How to hide a columns in a DataGridview.




Responses

Posted by: Satyapriyanayak on: 8/18/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
dataGridView1.Columns[0].Visible = false;

or
dataGridView1.Columns["id"].Visible = false;



private void Form1_Load(object sender, EventArgs e)
{

OleDbConnection con = new OleDbConnection(ConnectionString);
con.Open();
str = "select * from test";
com = new OleDbCommand(str, con);
oledbda = new OleDbDataAdapter(com);
DataSet ds = new DataSet();
oledbda.Fill(ds, "test");
dataGridView1.DataMember = "test";
dataGridView1.DataSource = ds;
//dataGridView1.Columns[0].Visible = false;
dataGridView1.Columns["id"].Visible = false;

}


If this post helps you mark it as answer
Thanks

Amulya, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 8/19/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Detailed description is available in the following link
http://msdn.microsoft.com/en-IN/library/hbtwc35f(v=vs.90).aspx

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Amulya, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nksingh420 on: 8/19/2013 [Member] Starter | Points: 25

Up
0
Down
write those column name which you want to display in datagridview

Amulya, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response