Solved

DELPHI - cxrid column value

Posted on 2011-09-22
4
560 Views
Last Modified: 2012-08-13
hi,

normally use the database queries, but now I need to work directly on the grid, use cxGrid.

How do I calculate the sum of the values ¿¿of all rows contained in a column?
0
Comment
Question by:danz67
  • 3
4 Comments
 
LVL 19

Expert Comment

by:Thommy
ID: 36579841
Summing multiple selected rows in a DBGrid
http://delphi.about.com/od/usedbvcl/a/tdbgrid.htm

You can implement it the same way with in a cxgrid...
0
 
LVL 19

Expert Comment

by:Thommy
ID: 36579864
0
 

Author Comment

by:danz67
ID: 36580136
I need to know the value calculated in a column for all rows
and the result must be displayed in a label
0
 
LVL 19

Accepted Solution

by:
Thommy earned 125 total points
ID: 36580799
Replace second parameter of function GetValue(i,3) with the index of your grid column (starting with 0).

Make sure that the column you want to sum only contains numeric values, otherwise you will get an error!!!


var
  i:integer;
  sum : integer 
begin
  for i:=0 to cxGrid1.DataController.RecordCount-1 do begin
    sum:=sum+cxGrid1.DataController.GetValue(i,3);
  end;
  label1.caption:=inttostr(sum);
end;

Open in new window

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now