Dear All
I have an windows application in which i'm using DataGridView control to show the data and in this i have a column as Grand Total Remaing are like sub1,Sub2,Sub3 etc
What i wanted to do is when user enters the values for Sub1 to Sub3 I want to show the Total Sum in the Grand Total Column
For this i have used _CellValueChanged ,this event is working fine when i kept a breakpoint and debug i'm getting the total value ,but if i remove the breakpoint i'm not getting any value ..
Please help me out
here is my sample code
datagridcontrol = (DataGridControl)wfhdgPestSplit.Child;
public CompanyWise()
{
datagridcontrol.dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(dataGridView1_CellValueChanged);
}
void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
//throw new NotImplementedException();
int column = e.ColumnIndex;
int row = e.RowIndex;
string str = datagridcontrol.dataGridView1[column, row].Value.ToString();
DataView dtDetails = new DataView();
dtDetails = (DataView)datagridcontrol.dataGridView1.DataSource;
GrandTotal(datagridcontrol.dataGridView1, row, column, 3);
}
private void GrandTotal(DataGridView dataGridView, int iRow, int iColumn, int iResultColumn)
{
DataView dtDetails = new DataView();
dtDetails = (DataView)dataGridView.DataSource;
int value = 0;
int value1 = 0;
for (int columnNo = 4; columnNo < dtDetails.Table.Columns.Count; columnNo++)
{
if (!string.IsNullOrEmpty(dtDetails.Table.Rows[iRow][columnNo].ToString()))
value = Convert.ToInt32(dtDetails.Table.Rows[iRow][columnNo].ToString());
else
value = 0;
if (value != 0)
{
value1 = value + value1;
}
}
dtDetails[iRow][iResultColumn] = value1;
//System.Windows.Forms.MessageBox.Show("Value is " + value1 + "and current value is " + value);
//datagridcontrol.dataGridView1.DataSource = dtDetails;
dataGridView.DataSource = dtDetails;
}
Best Regards