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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:41:43+00:00 2026-05-11T07:41:43+00:00

The DevExpress Grid (XtraGrid) allows grids and their groups to have summary calculations. The

  • 0

The DevExpress Grid (XtraGrid) allows grids and their groups to have summary calculations. The available options are Count, Max, Min, Avg, Sum, None and Custom.

Has anyone got some sample code that shows how to calculate a weighted average column, based upon the weightings provided as values in another column?

  • 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. 2026-05-11T07:41:44+00:00Added an answer on May 11, 2026 at 7:41 am

    I ended up working this out, and will post my solution here in case others find it useful.

    If a weighted average consists of both a value and a weight per row, then column that contains the value should have the weight GridColumn object assigned to its Tag property. Then, this event handler will do the rest:

    private static void gridView_CustomSummaryCalculate(object sender, CustomSummaryEventArgs e) {     GridColumn weightColumn = ((GridSummaryItem)e.Item).Tag as GridColumn;      if (weightColumn == null)         return;      switch (e.SummaryProcess)     {         case CustomSummaryProcess.Start:         {             e.TotalValue = new WeightedAverageCalculator();             break;         }         case CustomSummaryProcess.Calculate:         {             double size = Convert.ToDouble(e.FieldValue);             double weight = Convert.ToDouble(((GridView)sender).GetRowCellValue(e.RowHandle, weightColumn));              ((WeightedAverageCalculator)e.TotalValue).Add(weight, size);             break;         }         case CustomSummaryProcess.Finalize:         {             e.TotalValue = ((WeightedAverageCalculator)e.TotalValue).Value;             break;         }     } }  private sealed class WeightedAverageCalculator {     private double _sumOfProducts;     private double _totalWeight;      public void Add(double weight, double size)     {         _sumOfProducts += weight * size;         _totalWeight += weight;     }      public double Value     {         get { return _totalWeight==0 ? 0 : _sumOfProducts / _totalWeight; }     } } 

    The code assumes that the underlying column values can be converted to doubles via Convert.ToDouble(object).

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

Sidebar

Related Questions

I have a grid (DevExpress XtraGrid, if that matters) which is bound to a
I have Devexpress DropDownEdit control over Grid. One of the grids columns is Status
I have a devexpress Grid with GridView and there is the possibility to add
i have a DevExpress Grid and want to set up an edit Mask on
I have a DevExpress MVC grid that uses the following .BindToLINQ: .BindToLINQ(typeof(MyContext), Results, ((s,
VB .NET 4 WinForms application. I have a (DevExpress) grid bound to an IEnumerable(Of
I have a Devexpress DxGrid with two Columns with ComboboxEdit CellTemplate <dxg:GridControl Name=grid> <dxg:GridControl.Columns>
Does anyone knows how to get a DevExpress WPF Grid Rows count?
I have the following problem. With DevExpress I want to set an XtraGrid to
I have a DevExpress grid that needs to be refreshed every time the value

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.