Create DataGridView columns from Table values

Posted by fireBand on Stack Overflow See other posts from Stack Overflow or by fireBand
Published on 2010-04-22T14:59:07Z Indexed on 2010/04/22 15:03 UTC
Read the original article Hit count: 219

Filed under:

Hi,

I am using data grid view to display items as excel spread sheet in VB.NET. I got a table named CostTypes with column names [CostTypeID, CostType] and values [1,External] and [2,Internal] (These are constant but more values can be added to table).

I want to create columns with names of the values[External , Internal] in DataGridView. If I use databiding directly I get columns [CostTypeID,CostType] which is not what I am looking for.

If some one could explain how to create columns at runtime in datagridview or how to retrieve data from data base using LINQ so that [External , Internal] turn out to be columns that would be great.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about vb.net