Solved

Array's & Components

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now