Solved

Array's & Components

Posted on 1997-11-30
1
165 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
1 Comment
 
LVL 2

Accepted Solution

by:
kjteng earned 100 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi application Soap connection 5 121
Intraweb download file link ? 1 156
Run video youtube webbrowse 10 65
Making delphi communicate with a c# service 16 112
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…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

829 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