Help with datagrid
Well first of all sorry if this is a repeat question or question on the wrong section.
Here is what i want to do:
create a invoice, i am using datagridview.
it has columns like. "item" "particulars" "rate" "qty" "price".
user inputs the item and rate so when he makes change to the qty the price column should have value calculated as rate*qty.
I also want to show the grand total on a textbox.
I need help asap. PLEASE
Kirtan PatelPosted May 10, 2009, 3:17 PM
i think it was occurred because you copy pasted source code
Mail me your Database File at [email protected]
i will correct your Insert Statement
Happy Coding :)
utsav rathourPosted May 10, 2009, 2:08 PM
Kirtan PatelPosted May 10, 2009, 9:53 AM
Weather it is correct or
not Because in my case its working Fine
take a look at My Project Files
Download it From Here
http://www.mediafire.com/?sharekey=2e9d884c2476e3fad2db6fb9a8902bda
utsav rathourPosted May 10, 2009, 9:47 AM
Kirtan PatelPosted May 10, 2009, 12:41 AM
Post your code plz
utsav rathourPosted May 9, 2009, 8:31 PM
Kirtan PatelPosted May 9, 2009, 2:42 PM
then in DataGridView Cell Value changed Event Write code like Below
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
try
{
int RowIndex = e.RowIndex;
if (e.ColumnIndex == 2 || e.ColumnIndex == 3)
{
int Quntity = Convert.ToInt32(dataGridView1.Rows[RowIndex].Cells[2].Value);
int Rate = Convert.ToInt32(dataGridView1.Rows[RowIndex].Cells[3].Value);
dataGridView1.Rows[RowIndex].Cells[4].Value = Quntity * Rate;
int total = 0;
foreach (DataGridViewRow dr in dataGridView1.Rows)
{
total = total + Convert.ToInt32(dr.Cells[4].Value);
}
txtTotal.Text = total.ToString();
}
}
catch
{
}
You Will get Output Like Below
thats it
Happy Coding :)