Solved

DELPHI - cxrid column value

Posted on 2011-09-22
4
568 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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