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 6784035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:56:30+00:00 2026-05-26T16:56:30+00:00

I am trying to transfer my excel app to WPF datagrid. I am going

  • 0

I am trying to transfer my excel app to WPF datagrid. I am going to enter data to Column A and in column B I would like to make calculation taking previus cell and current cell of A column and add Column B previus cell.
calculation example : B2 = B1 + (A2-A1). What is best approach of doing so?

  • 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-05-26T16:56:30+00:00Added an answer on May 26, 2026 at 4:56 pm

    Personally, I’d start by creating a class that represents the records and implement INotifyPropertyChanged on that class.

    public class recordObject : INotifyPropertyChanged
    {
        private int a;
        public int A 
        { 
            get
            {
                return a;
            }
            set
            {
                a = value;
                OnPropertyChanged("A");
            }
        }
    
        private int b;
        public int B
        { 
            get
            {
                return b;
            }
            set
            {
                b = value;
                OnPropertyChanged("B");
            }
        }
    
        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
    

    Then, in your code behind on the window you’re showing the datagrid, you’ll want to subscribe to PropertyChanged on each object in the list. Then you’d have to manually compute the column values whenever those properties changed. Ick, I know, but it’d work.

    The property changed event would look like:

    void recordObject_PropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        var objectList = DataGrid.ItemsSource as List<recordObject>;
        var myRecord = sender as recordObject;
        if (objectList != null && myRecord != null)
        {
            int idx = objectList.IndexOf(myRecord);
            // Perform your calculations here using idx to access records before and after the current record
            // making sure to check for list boundaries for top and bottom.
            // Also note that this will likely kick off cascading event calls so make sure you're only changing
            // the previous or following record object.
        }
    }
    

    If you hook this event onto all the records in your bound list, then it’ll fire whenever any property is changed. In the class above, that’d apply to both A and B. You can filter which properties you’re interested in monitoring through e.PropertyName (a simple string comparison) and guage the business logic accordingly. If you want to maintain encapsulation, or at least, put the business logic for the object on the object itself, this method could be a static one on the class recordObject. You’d have to provide for getting hold of the datagrid from that static method, though (likely through a static property on your window). So:

    public static void recordObject_PropertyChanged(object sender, PropertyChangedEventArgs e)
    

    and connected so:

    record.PropertyChanged += new PropertyChangedEventHandler(recordObject.recordObject_PropertyChanged);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to transfer data from a DataSet into an Excel workbook. Unfortunately, I
I'm trying to transfer an entire column's worth of data from the backup database
I'm trying to transfer some data from Access to SQL Server 2000 (there are
I'm trying to read the POST data from a request with Transfer-Encoding: chunked while
I'm trying to transfer the data from my production DB to my staging DB
I am trying to export data from database to an excel sheet, using php
In my WCF service, when trying transfer large data I constantly get an error:
I am trying to transfer code used by Evergreen/jasmine combo. Going from an old
I am trying to transfer a table from MySQL to MSSQL using the data
I am trying to transfer data from a jsp file using a json object.

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.