Solved

DELPHI - cxrid column value

Posted on 2011-09-22
4
565 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

831 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