Link to home
Start Free TrialLog in
Avatar of FCapo
FCapo

asked on

Vb.net datagridview Column

Hi,

I`d like to add a column named "C" to my datagridview which will be the sum of each row in columns "A" and "B",

Like this :

column A  Column B   Column C
2                 5                  7

How would I add this column to my datagridview?

Thank you
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

You surely have a datatable behind your datagid? add a calculated column to your datatable as shown in https://msdn.microsoft.com/en-us/library/vstudio/zwxk25bd(v=vs.100).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1
Avatar of FCapo
FCapo

ASKER

I'm importing the data from excel into a dataset :

     Dim MyConnection As System.Data.OleDb.OleDbConnection
        Dim DtSet As System.Data.DataSet
        Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
        MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='S:\Cms\EnviroMap.xls';Extended Properties=Excel 12.0 Xml")
        MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [enviroMap$]", MyConnection)
        MyCommand.TableMappings.Add("Table", "Net-informations.com")
        DtSet = New System.Data.DataSet
        MyCommand.Fill(DtSet)
        DataGridView1.DataSource = DtSet.Tables(0)
        MyConnection.Close()

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial