Solved

DELPHI - cxrid column value

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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Suggested Courses
Course of the Month6 days, 21 hours left to enroll

623 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