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

x
?
Solved

Array's & Components

Posted on 1997-11-30
1
Medium Priority
?
172 Views
Last Modified: 2010-04-04
Hi i have a little problem,

I am writing an component, and i need a property with an array of a record.

e.g.

Type ItemRecord = Record
                   Name : String;
                   Enabled : Boolean;
                   Selected : Boolean;
                  End;

How can i make this array in the component ?

pleeeeeaaaaaaze help !

Thx, Arijan
0
Comment
Question by:aluiken
[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 2

Accepted Solution

by:
kjteng earned 300 total points
ID: 1352452
You can create an array property as the appende code. Please note that I have declared the array properties as public rather than published because I have not written a property editor for the particular property. As stated in the online help: "Array properties must have their own property editors. The Object Inspector has no built-in support for editing array properties".

type
  data= record
          Name : String;
          Enabled : Boolean;
          Selected : Boolean;
        end;
  test = class(TComponent)
  private
    { Private declarations }
    FRecList: array[1..100] of data;
  protected
    { Protected declarations }
  public
    { Public declarations }
    function getRecList(Index: Integer): data;
    procedure setRecList(Index: Integer; const value: data);
    property reclist[Index: Integer]: data read GetReclist write SetRecList;
  published
    { Published declarations }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [test]);
end;

function  test.getRecList(Index: Integer): data;
begin
    if Index>high(FRecList) then
    begin
      result.name:='';
      result.enabled:= false;
      result.selected:= false
    end
    else begin
      result:= FRecList[Index]
    end;
end;

procedure test.setRecList(Index: Integer; const value: data);
begin
  if Index>high(FRecList) then exit;
  FRecList[index] := value;
end;

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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 this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
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