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
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
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
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()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.