gd740

can i add the sum total of the column in the footer of listview?

gd740

the listview have 3 columns, and have few rows containing some data..
i have save the content into textfile and the output is like

LEE,06/08/2011,1000.00
KEVIN,08/08/2011,1600.00
SALAU,15/08/2011,800.00
..etc..
..etc..

the textfile data then i intend to insert into datagridview after opening the file..

However,i am now saving the listview item into csv file and then able to insert into datagridview.
But, i would be more than happy if you don't mind to show me on how to insert the textfile into DGV..
thank you very much for your reply too!! =D

gd740

but if there are many rows per line, how should i read it into datagridview?

gd740

it's ok now..i think i was refering to wrong table...thanks for the help ya!!! ^^

gd740

[QUOTE=adam_k;1589675]You lost me with the I want to add the values in the column the row.

Your code seems only to be adding the second from last row in datagridview, and then you try to add to total the value of row -1 (your counter is 0 and you subtract 1). (What does form1.textbox6 show?)

If I understand correctly you want to sum the column 6 (Amt) in your datagridview.

The easiest way to do this (at least in my book) is to have SQL calculate that for you. This can be done in the same query (with a union) or in a separate query. You can get the value and be done with it. It's way faster to ask SQL to do it for you, than calculating it.
As I believe that you don't want the total to appear on your gridview, I'll go with a separate query to get it. Also I'll use a binding to show data to the gridview, as it's faster and cleaner.
[CODE]
dim cmd as new sqlclient.sqlcommand
dim bind as new bindingsource

cmd.commandtext = "select product,Quantity,MRP,Sale_Rate,Disc_Amt,Amt from sale_table"
cmd.connection = con
con.open()

bind.datasource = cmd.executereader(CommandBehavior.CloseConnection)
DataGridView1.datasource = bind

cmd.commandtext = "select sum(Amt) from sale_table"
con.open()

textbox10.text = cmd.executescalar
cmd.dispose
con.close

[/CODE]

If you have to calculate the total from the datagridview:
[CODE]

    For i As Integer = 0 To DataGridView1.RowCount() - 1
        total += DataGridView1.Item(6, i).Value
    Next

    TextBox1.Text = total.ToString

[/CODE][/QUOTE]

hi adam...i would like to ask is that possible to insert the ...

gd740

hello, then how to achieve the option inserting the total of the sum into the mysql database?

gd740

thanks for the reply.
it works, but then it only insert into the combobox during runtime, and when i execute it again, it wont appear for the second time..
how should i insert into the mysql database so that it will exist for the next execution and exist in my database?
i am a beginner ..
thanks in advane :)

gd740 Newbie Poster

i have a combobox and few textboxes in Form1.
i inserted new item into combobox by entering new item in one of the textbox.
i manage to add item into combobox in Form 1.
But how can i achieve if the item i added in Form1 to be inserted automatically into Form2 combobox as well after the operation in Form1. How can i achieve that?

i am using vb and mysql as database

gd740

yes, i need to save all the information entered into mysql..

gd740 Newbie Poster

Hi, i am still a beginner in vb.net, please help me..

My question here is when i input data to a textbox1 and then i press enter using keyboard, then another description will appear in textbox2.

For example, i have to key in a company's code: A001 into textbox1, after i press Enter using keyboard, the company's full name will appear in textbox2.

i have no idea how it will be done..please kindly help me