Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4334044
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:28:31+00:00 2026-05-21T10:28:31+00:00

I am walking a form’s control list and when I find a TPicture I

  • 0

I am walking a form’s control list and when I find a TPicture I want to change a property (image, but anything will do for an example).

How do I code that? It seems like TPciture and TControl are not compatible. Can I cast somehow?


Update:
when I add this code

for i:= 0 to Pred(designerForm.ControlCount) do
    if designerForm.Controls[i] is TPicture then
     MessageDlg('Picture : ' + designerForm.Controls[i].name, 
                               mtInformation, [mbOK], 0);

where designerForm is TForm, I go from zero to two errors in D7

[Error] PictureInspEditor.pas(121): Incompatible types: 'TPicture' and 'TControl'
[Fatal Error] E_logger.dpr(22): Could not compile used unit 'PictureInspEditor.pas'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T10:28:31+00:00Added an answer on May 21, 2026 at 10:28 am

    Are you sure when you say TPicture maybe do you really want to say TImage?, anyway in any case first you must check if the current control is of the class which you want evaluate TImage (in this case) then you can cast in this way TImage(Controls[i])

    check this sample for a TImage

    var
      i  : Integer;
    begin
      for i := 0 to ControlCount-1 do
        if Controls[i] is TImage then
         begin
           // do your stuff here 
           TImage(Controls[i]).Picture:=aValue;
         end;
    end;
    

    UPDATE
    you can’t compare the TPicture class against the TControl using the is operator because the type of the TPicture is unrelated to the TControl.

    from the Embarcadero documentation

    The is Operator …..If the declared type of object is
    unrelated to class – that is, if the
    types are distinct and one is not an
    ancestor of the other a compilation
    error results

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I frequently find myself creating classes which use this form (A): abstract class Animal
I want to be able to test my app while walking around my house,
Ok, I'm certainly familiar with walking through a table using a read-only cursor, but
I'm walking through a small example to hit https web services. It requires building
Garbage collection involves walking through a list of allocated objects (either all objects or
I am walking through the Cython documentation and building each of the example apps.
I want to make a game where you have little avatars walking over pages,
I am walking through the MS Press Windows Workflow Step-by-Step book and in chapter
I am trying to write a form to help users make canned pdfs im
I'm walking you through a processs here: Step 1 1. Select product from dropdownlist

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.