Page 1 of 1

Addressing individual Gantt bars

Posted: Tue Aug 02, 2005 9:36 am
by 9337081
When creating a bar in a Gantt diagram with e.g. AddGanttColor, the function returns a index value as, according to the help file, can be used to address the bar.

When I create multiple bars on each line, the returned index value is re-used sometimes (have not figured out the pattern) and is therefore not useable for identifying each individual bar. Why is that? Have I misunderstood the concept of the returned index value?

What I need is to be able to identify what individual bar is being clicked. Is there a way of accomplishing this by other means than the above mentioned index value?

Thanks!
Jon

Posted: Tue Aug 02, 2005 10:36 am
by Pep
Hi Jon,
What I need is to be able to identify what individual bar is being clicked. Is there a way of accomplishing this by other means than the above mentioned index value?
Yes, you could use the OnClick event of the Gantt Series, which returns the ValueIndex of the gantt clicked, or you can use the Clicked method :

Code: Select all

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
  var  clickedIndex : integer;
begin
  ClickedIndex := Series1.Clicked(x,y);
  ShowMessage(inttostr(ClickedIndex));
  abort;
end;
Maybe what you're trying to accomplish is similar to the Gantt Drag Tool ? Have you seen it ? You can find one example in the Demo Features project.

Posted: Tue Aug 02, 2005 12:28 pm
by 9337081
Hi Pep,

Thanks for the reply.

Meanwhile, I found this explanation (through Google Groups search) to the strange index numbers:

>David Berneda 23 Mar 1998 10:00 wrote:
>
>By default, Gantt series sort points by X values.
>Disabling X sorting ( or calling AddGantt with X values sorted ) will >maintain the index numbers.
>
>Series1.XValues.Order := loNone ;
>Series1.AddGantt...
>Series1.AddGantt...
>
>In your code, the second gantt bar has a lower X value than the
>first. So that's why the index is zero in the two cases.

This worked for me and gave me some relief this afternoon. 8)

Thanks again!
Jon