Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Casting a TList Item

Posted on 1997-06-10
1
Medium Priority
?
555 Views
Last Modified: 2012-05-07
How can I cast a TList item?  I have a TList object that contains TStringLIst objects.  I want to do a find on the TSTringList, but I can't cast it.  Here are the things I have tried:

   MyString := MyTList.Items[0].Strings[0] ;
Error: Record, object, or class type required.

   MyString := (MyTList.Items[0] as TStringLIst).Strings[0] ;
Error: Operator not applicable to this operand type.

I realize that MyTList.tems[0] is actually returning a pointer, but I can't figure out how to turn that into something I can use.  I also realise that I can assign MyTList.Items[0] to a temporary variable that is typed as a TStringList, but that is a pain in the ass.  It also makes the code a lot more complicated when I am looping through a TList of TStringLIsts.

-- Clayton --
0
Comment
Question by:Clayton Neff
[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
1 Comment
 
LVL 4

Accepted Solution

by:
erajoj earned 200 total points
ID: 1336928
Like this:

MyString := TStringList(MyTList.Items[0])[0];

/// John

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

604 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