Solved

Array's & Components

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

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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

726 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