Page 1 of 1

setting the brush style on an individual Gantt

Posted: Sat Oct 06, 2007 11:35 pm
by 9345379
I would like to be able to change the brush style of an individual Gantt in run time. My intention would be to permit the user to R click on the Gantt and to open a Pop-up menu where the change could be selected.

Right now I am accessing Gantt properties by passing the GanttBar value to my object and making changes and assigning them back to the Gantt. That is fine except that I can not know the Gantt Bar index unless I move the Gantt. I would really like to know the Gantt by simply clicking on it. Is this possible? How woudl I do this?

Thanks

Posted: Mon Oct 08, 2007 9:11 am
by narcis
Hi Gainco,

This is pretty easy. You can use series' OnClick event like this:

Code: Select all

procedure TForm1.Series1Click(Sender: TChartSeries; ValueIndex: Integer;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  Chart1.Title.Text[0] := 'Series index: ' + IntToStr(ValueIndex);
end;

Posted: Mon Oct 08, 2007 3:37 pm
by 9345379
Okay,
Now that I have a value that corresponds to the GanttBar, how do I get this back to the TGanttTool?
The only way I have of getting to the GanttTool is through it's sender.

Let's approach it this way.


I want to change the Brush for one Gantt when I doubl-click on it.
How do I do that?
Thanks,
Larry

Posted: Mon Oct 08, 2007 3:46 pm
by narcis
Hi Larry,
Now that I have a value that corresponds to the GanttBar, how do I get this back to the TGanttTool?
The only way I have of getting to the GanttTool is through it's sender.
You should save the index in a global variable and use it later with the GanttBar. You could also obtain the index with TChart's OnMouseDown event like this:

Code: Select all

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var Index: Integer;
begin
  Index := Series1.Clicked(X,Y);

  if Index <> -1 then
  begin
    //Assign Index to a global variable
  end;
end;
Let's approach it this way.

I want to change the Brush for one Gantt when I doubl-click on it.
How do I do that?
Ok, you can do use OnDblClick event like this:

Code: Select all

procedure TForm1.Series1DblClick(Sender: TChartSeries; ValueIndex: Integer;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  Sender.ValueColor[ValueIndex]:=clLime;
end;

Posted: Mon Oct 08, 2007 4:13 pm
by 9345379
Yes, this works fine for color but can you show me how to change the Brush type?

Posted: Tue Oct 09, 2007 8:15 am
by narcis
Hi Gainco

I'm afraid it's not possible setting a different brush style for each gantt bar.