Solved

Try to create a component with a TStrings property

Posted on 2002-03-23
1
264 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
1 Comment
 
LVL 9

Accepted Solution

by:
ITugay earned 50 total points
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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 shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

10 Experts available now in Live!

Get 1:1 Help Now