locked
A question about DataGridView bind with objects RRS feed

  • Question

  • Hey all,

    I have a list of objects, for example a list of Car objects. The Car object has 4 data fields: "Brand", "Model", "Year" and "Price". I bind this list with a DataGridView. However, I don't want to show the information about the "Price". Is there any way I can only display three columns?

    Thanks in advance.

    Sunday, September 9, 2012 11:20 AM

Answers

  • After bindig, simply hide the column(s) you dont want to show:

    //binding...
    //then hide - (by index):
    dataGridView1.Columns[3].Visible = false; 
    //or by column name:
    dataGridView1.Columns["Price"].Visible = false;
    

    Hope it helps,

    bye


    Mitja

    Sunday, September 9, 2012 11:37 AM