troubleshooting Question

Typecasting an object list into another object

Avatar of Fled
Fled asked on
4 Comments1 Solution351 ViewsLast Modified:

I create some object wich is define like this:

                 FAdresseList (AddObject of TAdresse into the stringlist);  like FAdresseList.AddObject(......, ...);  //No Message error
      TClient (is a descendant of TPersonne)                    

In my form i use:  One ListBox wich i add these object into it...


  For nCount := 0 to ClientDatasetclient.RecordCount - 1 do
      UnClient := TClient.create;
      UnClient.Raz;  //erase everything
      UnClient.Nom := Trim(ClientDataSetClient.FieldByName('Chr_Client_Nom').Value);
      UnClient.ID := ClientDataSetClient.FieldValues['int_Client_ID'];


      {Lecture de la table adresse}
      for xCount := 0 to CDSAdresse.RecordCount - 1 do
          Indice := CDSAdresse.FieldValues['int_cl_id'] ;
          if (UnClient.ID = CDSAdresse.FieldValues['int_cl_id']) then
               UnAdresse := TAdresse.Create;
               UnAdresse.Raz;  //erase everything

               UnAdresse.AdresseID    := CDSAdresse.FieldValues['int_AdresseID'];
               UnAdresse.Adresse       := CDSAdresse.FieldValues['chr_Adresse'];
               UnAdresse.Adresse1     := CDSAdresse.FieldValues['chr_Adresse1'];
               UnAdresse.Suite           := CDSAdresse.FieldValues['chr_Suite'];
               UnAdresse.Ville            := CDSAdresse.FieldValues['chr_Ville'];
               UnAdresse.Suite          := CDSAdresse.FieldValues['chr_Suite'];
               UnAdresse.Ville           := CDSAdresse.FieldValues['chr_Ville'];
               UnAdresse.Etat           := CDSAdresse.FieldValues['chr_Province'];
               UnAdresse.Pays           := CDSAdresse.FieldValues['chr_Pays'];
               UnAdresse.CodePostal := CDSAdresse.FieldValues['chr_CodePostal'];
               UnAdresse.AdresseGenre := CDSAdresse.FieldValues['INT_ADRESSETYPE'];

             UnClient.AjoutAdresse(UnAdresse); //Add adresse into the list
      LaListe.Items.AddObject(UnClient.Nom, UnClient); // Add Client into the list.




In the debug mode, the data is there...   I even try to fake the data, so it goes into the liste of adresse..

I have a listbox with Object of TClient fill with another Listof Object of TAdresse.  But when i try to access it from the ListBox it dosen't work well..

If i use   Showmessage(Trim(TClient(ListClients.Items.Objects[ListClients.ItemIndex]).Nom)); it's work to access the client name...

But when i try to access the adresse of that object into the same list box it's not working...  I have difficulties to Typecast 2 object...


It dosen't gave me any error, but the data is not there..  

First.. Is this a good way to typecast an object into another list of obejct into the same object object, and into the same list?  I know it's weird... difficult to explain to! ;)


Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros