I have a listview component in my project, and it has a Column with multiple values entered. Anyone has any idea how I can add an entire column of the listview that only include values of type:
300,00
52,00
100,00
Thanks for any help ....
I have a listview component in my project, and it has a Column with multiple values entered. Anyone has any idea how I can add an entire column of the listview that only include values of type:
300,00
52,00
100,00
Thanks for any help ....
This is part of the source code of a form I created to test the solution.
type
TfrmPrincipal = class(TForm)
lvLista: TListView;
btnSoma: TButton;
procedure btnSomaClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmPrincipal: TfrmPrincipal;
implementation
{$R *.dfm}
procedure TfrmPrincipal.btnSomaClick(Sender: TObject);
var
dSoma : double;
i : integer;
begin
dSoma := 0;
for i := 0 to MyListView.Items.Count - 1 do begin
dSoma := dSoma + StrToFloatDef( MyListView.Items[ i ].Caption, 0 );
end;
ShowMessage( FloatToStr( dSoma ) );
end;
Tested on Delphi7.
The ".Caption" accesses the value of the first column. If it is necessary to access others, ".SubItems [x]" should be used, remembering that "x" is equal to "column number" minus 2.
Examples: