FNCGantt problems

Hello,
I'm having a few minor problems with the FNCGanttchart component.
I'm using a database and accessing the data using a Devart SQL component. I create the Gantt chart in the query. If I use the AddTask function, the Gantt chart creation works. However, since I don't know how to populate the "Hint" and "Description" properties, I create the Gantt chart using "project.tasks.add" and populate the properties. However, with this method, only one record is created. As soon as the database accesses the second record, an error occurs stating that the database query is closed.
Here are the two short code snippets. The first query works great, but I don't know how to assign the hint and description, hence the second query, where an exception occurs on Next. Something in project.task.add seems to be triggering "active:=false" and closing the database.
SQL query
while not eof do
begin
Addtask(..)
next
end

Error with
SQL query
while not eof do
begin
with project.task.add do
begin
name:=...
Description:=...
end
next -> this is where the crash occurs

Then there's another problem. If I set "locked:=true", the planned date is set to 12/31/1899 and the duration to 1. What am I doing wrong here? I would like to keep the planned date unchanged and simply prevent the entry from being moved by setting locked:=true.
Many thanks
Steffen Weiner

I assume as you are handling the database reading and writing in your own code and that you are not usin the GanttDataBaseAdapter? Otherwise this might be causing issues.

For best practice we also advise to not use with statements this might also give problems with some properties.

You can use AddTask for this as this also returns a GanttTask:

  TMSFNCGanttChart1.Project.AddTask('Name','Description', ...).Hint := 'Hint';

Or if you want to set other properties as well:

var
  t: TTMSFNCGanttTask;
begin
  t := TMSFNCGanttChart1.Project.AddTask('Name','Description', ...);
  t.Hint := 'Hint';

For your problem with the Locked property, it is necessary to set this after the PlannedStart and Duration was set. As this blocks all ways to modify the date.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.