Hello, i want to show the opening and closing balance in datagridview.
so, i tried below code on datagridview's sorted event.
- private void dataGridView1_Sorted(object sender, EventArgs e)
- {
- try
- {
- for (int i = 1; i < dataGridView1.Rows.Count - 1; i++)
- {
- if (dataGridView1.Rows[i].Cells[4].Value.ToString() != "0")
- {
- dataGridView1.Rows[i].Cells[5].Value = Convert.ToInt32(dataGridView1.Rows[i-1].Cells[5].Value) - Convert.ToInt32(dataGridView1.Rows[i].Cells[4].Value);
- }
- else
- {
- dataGridView1.Rows[i].Cells[5].Value = Convert.ToInt32(dataGridView1.Rows[i - 1].Cells[5].Value) + Convert.ToInt32(dataGridView1.Rows[i].Cells[1].Value);
- }
- }
- }
- catch (Exception ex)
- {
- }
- }
But as per my requirement i want this type of output in datagridview
so help how can i do this ?
Laxmidhar SahooPosted Apr 14, 2019, 7:56 AM