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
Visual Basic.NET.NET Programming

Avatar of undefined
Last Comment
Éric Moreau

8/22/2022 - Mon
Éric Moreau

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
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
Éric Moreau

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Your help has saved me hundreds of hours of internet surfing.
fblack61