Click here to Skip to main content
15,891,749 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have Columns 4 5 and 6 and i want to display them in colm 7

ex.
Name Col4 col5 col6 Total
Stephen 2 3 6
JOhn 5 9 11

this is what i have so far

Dim col1 As Integer
Dim col2 As Integer
Dim col3 As Integer
Private Sub dataGridView1_CellLeave(sender As Object, e As DataGridViewCellEventArgs)
If e.ColumnIndex = 4 Then
col1 = Integer.Parse(dataGridView1(1,e.RowIndex).Value.ToString())
col2 = Integer.Parse(dataGridView1(2,e.RowIndex).Value.ToString())
col3=col1+ col2;
dataGridView1(3, e.RowIndex).Value = (col3).ToString()
End If
End Sub
Posted
Comments
sv sathish 15-Aug-13 10:39am    
i help you but your question is not understandable so update your question in easy manner.
what is use of "Total" in Gridview1.
PythonProgrammer 15-Aug-13 10:46am    
ok so i have 4 columns fruits, snacks, vegetables, and total....
Stepehn 5 7 15
John 6 19 23

I want to display the total in the columns
sv sathish 15-Aug-13 10:59am    
U want like this
-----------------------------------------------
Name | Fruits | Snacks | Vegetables | Total
-----------------------------------------------
xxxx | 2 | 2 | 2 | 6
yyyy | 1 | 1 | 1 | 3
-----------------------------------------------
PythonProgrammer 15-Aug-13 11:00am    
yes that is correct sorry for the explanation of this im a begginner at this and seeing what to do helps me understand it
PythonProgrammer 15-Aug-13 11:33am    
im not using a database

U can try this

Imports System.Data.OleDb
Public Class help
Dim con As OleDbConnection
Dim cmd As OleDbCommand
Dim adp As OleDbDataAdapter


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
con = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=D:\Database3.mdb")
con.Open()
Dim qry As String
qry = "INSERT INTO total( [name], [sal1], [sal2] , [sal3], [total]) VALUES('" & TextBox1.Text & "' ," & TextBox2.Text & " ," & TextBox3.Text & "," & TextBox4.Text & "," & Val(TextBox2.Text) + Val(TextBox3.Text) + Val(TextBox4.Text) & ")"
cmd = New OleDbCommand(qry, con)
cmd.ExecuteNonQuery()
MsgBox("Total Added ")
End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900