Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Delphi
  4. [SOLVED] Set/Get ItemData() Equivalent in Delphi

[SOLVED] Set/Get ItemData() Equivalent in Delphi

Scheduled Pinned Locked Moved Delphi
c++delphi
2 Posts 2 Posters 6 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AmbiguousName
    wrote on last edited by
    #1

    hello guys.. I am new to Delphi. Some of you might have worked in C++. Is there anyway we could use these methods for associating 32-bit values, in Delphi. I also watched functions of TCustomCombo but could not find these methods. Thanks for any pointers.

    This world is going to explode due to international politics, SOON.

    S 1 Reply Last reply
    0
    • A AmbiguousName

      hello guys.. I am new to Delphi. Some of you might have worked in C++. Is there anyway we could use these methods for associating 32-bit values, in Delphi. I also watched functions of TCustomCombo but could not find these methods. Thanks for any pointers.

      This world is going to explode due to international politics, SOON.

      S Offline
      S Offline
      smags13
      wrote on last edited by
      #2

      Basically, you need to set/get Object into/from Items property of TComboBox instance. An example could be found at TComboBox.Items Property[^] To set:

      // Add View styles and constants to the Combo Box
      ComboBox1.Items.AddObject('vsIcon', TObject(vsIcon));
      ComboBox1.Items.AddObject('vsList', TObject(vsList));
      ComboBox1.Items.AddObject('vsReport', TObject(vsReport));
      ComboBox1.Items.AddObject('vsSmallIcon', TObject(vsSmallIcon));
      // Display first item in the Combo Box
      ComboBox1.ItemIndex := 0;

      To get:

      ListView1.ViewStyle := TViewStyle(Items.Objects[ItemIndex]);

      TComboBox uses an instance of TCustomComboBoxStrings to maintain captions and their associated data, which has a function called PutObject.

      function PutObject(Index: Integer; AObject: TObject); override;

      This is the function that sends CB_SETITEMDATA message internally and where you could be able to set 32-bit value along with a given item index. On the other hand, GetObject

      function GetObject(Index: Integer): TObject;

      will retrieve the 32-bit value for you. Notice, in the world of Delphi, all these 32-bit values here are actually a TObject value.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups