"access vioaltions" when clicking on TListView

Posted on 2004-11-06
Last Modified: 2010-04-05
i have a TListView on the form. in the onClick event i have this code:
if ListView1.Selected.Index = 0 then ShowMessage('You clicked on the first item');

when i click on the listview (but not on an item) an error accours: access violations at adress 00445F54 in module 'Project1'. Read of address 00000004.

i am using delphi 4.
Question by:din345
    1 Comment
    LVL 27

    Accepted Solution


    if assigned(ListView1.Selected) and (ListView1.Selected.Index = 0)
      then ShowMessage('You clicked on the first item');

    make sure that one is selected

    hope thats it

    meikl ;-)

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    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 The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now