[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Problem in a Component derived from TClientDataSet using TStrings

Posted on 2009-05-15
7
Medium Priority
?
381 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

This is about my first experience with programming Arduino.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Introduction to Processes
Suggested Courses

649 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