TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
-
henry20
- Newbie
- Posts: 2
- Joined: Thu Mar 24, 2016 12:00 am
Post
by henry20 » Sat Jun 11, 2016 6:50 am
i'm a newbie and i'm working on a C++ VCL project with a StringGrid and a GanttChart. What i want to do is to "update" the gantt bar automatically once a new data is entered into the StringGrid.
What i do first is to create a chart with bars with this command:
Code: Select all
TGanttSeries *Series1;
int i = 0;
Series1 = new TGanttSeries(this);
Series1->AddGantt(StrToDate(StringGridEd1->Cells[4][1]),StrToDate(StringGridEd1->Cells[5][1]), i,"Task"+IntToStr(i));
Series1->ParentChart = Chart1;
That's perfect for creating a chart but how do i update the gantt's bar date so the bar automatically resize itself? For example if the user enter 1 day, the gantt bar display only 1 day and when the user enter 5 day the gantt bar automatically "resize" itself from 1 to 5 days.
Is there any function or properties which can do this for me?
-
Yeray
- Site Admin
- Posts: 9614
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Mon Jun 13, 2016 11:03 am
Hello,
If I understand it correctly, you can update your series StartValues/EndValues at the StringGrid1SetEditText event. Ie:
Code: Select all
TGanttSeries *Series1;
void __fastcall TForm1::FormCreate(TObject *Sender)
{
StringGrid1->ColCount = 6;
StringGrid1->RowCount = 2;
StringGrid1->Cells[4][1] = "01/01/2016";
StringGrid1->Cells[5][1] = "02/01/2016";
StringGrid1->Options << goEditing;
int i = 0;
Series1 = new TGanttSeries(this);
Series1->AddGantt(StrToDate(StringGrid1->Cells[4][1]),StrToDate(StringGrid1->Cells[5][1]), i,"Task"+IntToStr(i));
Series1->ParentChart = Chart1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::StringGrid1SetEditText(TObject *Sender, int ACol, int ARow,
const UnicodeString Value)
{
TDateTime tmp;
if ((ACol==4) || (ACol==5)) {
if (TryStrToDate(StringGrid1->Cells[ACol][ARow], tmp)) {
if (ACol==4) {
Series1->StartValues->Value[ARow-1] = tmp;
Series1->StartValues->Modified = true;
}
else {
Series1->EndValues->Value[ARow-1] = tmp;
Series1->EndValues->Modified = true;
}
}
}
}