?
Solved

Problem in a Component derived from TClientDataSet using TStrings

Posted on 2009-05-15
7
Medium Priority
?
379 Views
Last Modified: 2012-05-07
Hello ,

      I want to create a Custom Component based on the TClientDataset class. I want my new component to be able to hold some strings in a TstringList. I have used the same technique in some other components and worked fine. No when I am trying to open the TStrings Editor in the Object Inspector the following error message appears "Could not assign a nil to a TRichEditStrings". What may be wrong ?

Thank you in advance.
TMySecondClientDataset = class(TClientDataSet)
  private
    FFileGroups: TStrings;
  protected
    constructor Create(AOwner : TComponent);
    destructor Destroy;
  public
  published
    property FileGroups: TStrings read FFileGroups write FFileGroups;
  end;
 
constructor TMySecondClientDataset.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FFileGroups := TStringList.Create;
end;
 
destructor TMySecondClientDataset.Destroy;
begin
  FFileGroups.Free;
end;

Open in new window

0
Comment
Question by:ikaros23
[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
  • 4
  • 3
7 Comments
 
LVL 38

Accepted Solution

by:
Geert Gruwez earned 750 total points
ID: 24393263
you need a setter to check for nil
type
  TMySecondClientDataset = class(TClientDataSet)
  private
    FFileGroups: TStrings;
    procedure SetFileGroups(const Value: TStrings);
  public
  published
    property FileGroups: TStrings read fFileGroups write SetFileGroups;
  end;
 
procedure TMySecondClientDataset.SetFileGroups(const Value: TStrings);
begin
  fFileGroups.BeginUpdate;
  try
    if Assigned(Value) then 
      fFileGroups.Assign(Value)
    else 
      fFileGroups.Clear;
  finally
    fFileGroups.EndUpdate;
  end;  
end;

Open in new window

0
 

Author Comment

by:ikaros23
ID: 24393331
I tried your solution but nothing happened :(. In another component that I have created (derived from TADOQuery) The same technique worked fine . Why would I need a setter procedure in this one ? I am very confused :( ......
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 24393804
did you assign nil ?

you want to assign the content of the list ,
not the list itself
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Closing Comment

by:ikaros23
ID: 31581831
Your setter procedure was right. What I though was right in the components I told you I have used the same technique proved to be wrong.I had written a property editor to access the strings . when I used the default the same error occurred. Although I have used a slightly different approach than the one you suggested (taken by FSQL property of ADOQuery) , I am accepting your solution , because its essentially the same. Thank you very much,
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 24394614
but why then a B grade ?
0
 

Author Comment

by:ikaros23
ID: 24397948
Sorry for the B . I am new to the experts and placed a B by mistake ... SORRYYYY :(
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 24400097
lol, no need to apologize, i was just wandering why ...
just follow the guide lines.
post a A, when accept,
post a B when you had to solve yourself and further investigation didn't help
post a C ... nobody likes this ...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This is about my first experience with programming Arduino.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Progress
Suggested Courses

764 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