Solved

Array's & Components

Posted on 1997-11-30
1
163 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

778 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