Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8103027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:24:16+00:00 2026-06-05T23:24:16+00:00

I have a datagridview which is editable. I have a textbox below it. I

  • 0

I have a datagridview which is editable. I have a textbox below it. I am entering the values in the grid view on run time and calculating the total in the textbox below it. The problem is, whenever i change the value in the grid view, the textbox retains the previous value and adds the new value to previous. I dont want the old value to be added. I wrote this code

private void grdPurchase_CellEndEdit_1(object sender, DataGridViewCellEventArgs e)
{
   try
   {
        //this.grdPurchase.Refresh();
       (grdPurchase.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() != "")
        string value = grdPurchase.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();

        if (e.ColumnIndex == 4)
        {

            float val = float.Parse(value);
            total = val;
            if (vapasi1 == "Yes")
            {
                if((e.r
                vtot += total;
                txt_forvapasitotal.Text = vtot.ToString();
                float vapsitot = float.Parse(txt_forvapasitotal.Text);
                float vapsicalculate = (vapsitot * a);
                float tax = vapsicalculate / 100;
                float with_vapasi = vtot + tax;
                txt_withvapasi.Text = Convert.ToString(with_vapasi);

            }
            else
            {
                nvtot += total;
                txt_withoutvapasitot.Text = nvtot.ToString();
            }
            txt_vapasiincludedtot.Text = (float.Parse(txt_withvapasi.Text) + float.Parse(txt_withoutvapasitot.Text)).ToString();
            }
        }

    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message.ToString());
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:24:18+00:00Added an answer on June 5, 2026 at 11:24 pm

    Try using the event DataGridView.CellValueChanged. An example can be find on MSDN. http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.cellvaluechanged

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGridView with read-only mode set to true (non-editable) which takes values
I have a datagridview which I fill it as below : var q= repository.GetStudents();//
I have a datagrid view which is editable. I'm getting the value of a
I have a DataGridView which I populate with values as soon as they are
I have a datagridview which we will call dataGridViewExample. My object (the uncommon datatypes
I have a DataGridView which is filling from Table in SQL Server Database. One
I have a datagridview in which one column contains a custom class, which I
I'm developing a window application in C# VS2005. I have a dataGridView in which
I have a Form with a DataGridView which DataSource is a BindingSource to a
I have a dataGrid(not dataGridView) in which i need to add Checkbox dynamically at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.