Solved

Try to create a component with a TStrings property

Posted on 2002-03-23
1
281 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

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