Solved

Try to create a component with a TStrings property

Posted on 2002-03-23
1
288 Views
Last Modified: 2010-04-05
I try to create a comonent
When i put the component on a form and click on nstring I get an Abstract Error.


unit Str;
interface
uses
  Windows, Messages, SysUtils, Classes, StdCtrls;
type
  TStr = class(TComponent)
  private
  protected
    astring : TStrings;
  public
    constructor Create(AOwner: TComponent);  override;
    destructor Destroy; override;
  published
    property nstring: TStrings READ astring WrITE astring;
  end;

procedure Register;

implementation

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

constructor TStr.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  astring := TStrings.Create;
end;

destructor TStr.Destroy;
begin
 inherited Destroy;
end;

end.
0
Comment
Question by:delpro
[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 9

Accepted Solution

by:
ITugay earned 50 total points
ID: 6890631
Hi delpro,


1. Do not use TStrings.Create, use TStringList.Create instead.

astring := TStringList.Create;

2. property nstring: TStrings READ astring WrITE astring;

should be changed to

property nstring: TStrings READ astring  write SetAstring;

procedure TStr.SetAString(Value: TStrings);
begin
  astring.Text := Value.Text;
  // or astring.Assign(Value);
end;

-----
Igor.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
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 …

717 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