Solved

listview subitems problem.

Posted on 2009-05-10
3
220 Views
Last Modified: 2012-05-06
look at this line SubItems.Add(FloatToStr(Bumpri));

I need to add subitems based on the caption.
if (label1.Caption = 'R & I Ft Bumper')  then
      sum:= Bumpri * LaborX;
    if (label1.Caption = 'R & I  Lt Head Light')  then
      sum:= rilftheadlilght * LaborX;
    if (label1.Caption = 'R & I Hood')  then
      sum:=  rihood *   laborx ;<<<<<<<
How can i know which caption was used to do the math so I know which On to insert into the listview.
var
Hale,Dent: Boolean;
 rihood, rilftheadlilght, bumpri: Double;
  Sum, laborx: Double;
  ListItem: TListItem;
begin
  Dent:= datamodule1.AQcustomerinfo.FieldByName('DentWork').AsBoolean;
  Hale:= Datamodule1.AQcustomerinfo.FieldByName('HaleWork').AsBoolean;
 
    If Copy(Label1.Caption,1,5) = 'R & I' Then
    begin
      Bumpri:= 1.5;
      rilftheadlilght:= 1.3;
      rihood:= 1.2;
      Laborx:= StrToFloat(frmsetup.Edit5.text);
    if (label1.Caption = 'R & I Ft Bumper')  then
      sum:= Bumpri * LaborX;
    if (label1.Caption = 'R & I  Lt Head Light')  then
      sum:= rilftheadlilght * LaborX;
    if (label1.Caption = 'R & I Hood')  then
      sum:=  rihood *   laborx ;
    begin
    ListItem := form1.ListView1.Items.Add;
     with ListItem do
     begin
     Caption := Datamodule1.AQGlobalID.fieldbyname('GlobalID').AsString;// first column
     SubItems.Add(Form1.Label1.Caption);
     SubItems.Add(FloatToStr(Bumpri));
     SubItems.Add('');
     SubItems.Add('');
     SubItems.Add('');
     SubItems.Add('');
     SubItems.Add(floattostr(sum)) ;
     
     end;
    end;
      end
      else
    if  Dent = True then
  begin
  frmDentRepair.Label3.Caption:= 'Operations:  '+ Form1.Label1.Caption;
  frmDentRepair.ShowModal;
  End
  else
   if Hale = True then
   begin
   frmDentRepair.Label3.Caption:= 'Operations:  '+ Form1.Label1.Caption;
   frmHale.ShowModal;
   end
 
 end;

Open in new window

0
Comment
Question by:Grant Fullen
[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
  • 2
3 Comments
 
LVL 22

Expert Comment

by:8080_Diver
ID: 24351069
How about setting an integer variable to a differnt value for each of the captions you are testing and then using that in a Case statement to determine what to do?

    if (label1.Caption = 'R & I Ft Bumper')  
    then begin
      sum:= Bumpri * LaborX;
      ActionNdx := 0;
    end
    else begin
      if (label1.Caption = 'R & I  Lt Head Light')  
      then begin
        sum:= rilftheadlilght * LaborX;
        ActionNdx := 0;
      end
      else begin
        if (label1.Caption = 'R & I Hood')  
        then begin
          sum:=  rihood *   laborx ;
          ActionNdx := 0;
        end
        else begin
          rasie Exception.Create("We should never get here!");
        end; {if}
      end; {if}
    end; {if}
  
    case ActionNdx of
      0 : begin
          end;
      0 : begin
          end;
      0 : begin
          end;
     else begin
          end;
    end; {case]

Open in new window

0
 
LVL 22

Accepted Solution

by:
8080_Diver earned 250 total points
ID: 24351077
Oops, clicked too soon! ;-)

    if (label1.Caption = 'R & I Ft Bumper')  
    then begin
      sum:= Bumpri * LaborX;
      ActionNdx := 0;
    end
    else begin
      if (label1.Caption = 'R & I  Lt Head Light')  
      then begin
        sum:= rilftheadlilght * LaborX;
        ActionNdx := 1;
      end
      else begin
        if (label1.Caption = 'R & I Hood')  
        then begin
          sum:=  rihood *   laborx ;
          ActionNdx := 2;
        end
        else begin
          rasie Exception.Create("We should never get here!");
        end; {if}
      end; {if}
    end; {if}
  
    case ActionNdx of
      0 : begin
          end;
      1 : begin
          end;
      2 : begin
          end;
     else begin
          end;
    end; {case]

Open in new window

0
 

Author Closing Comment

by:Grant Fullen
ID: 31579960
Thank you.
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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 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