2016-06-11 139 views
0

我是一个新手,我正在使用StringGrid和甘特图来处理C++ VCL项目。我想要做的是在一个新数据输入到StringGrid中时自动“更新”甘特条。在C++中的Teechart甘特图日期

我要做的首先是创建与此命令栏的图表:

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; 

这非常适合在创建图表,但如何更新甘特的酒吧约会,因此栏会自动调整自身的大小?例如,如果用户输入1天,则甘特条仅显示1天,并且当用户输入5天时,甘特条自动从1到5天“调整”其自身。

是否有任何功能可以为我做到这一点?

回答

1

我刚在Steema Software官方论坛(here)回复了你。
我在这里复制答案:

如果我理解正确,可以在StringGrid1SetEditText事件中更新您的系列StartValues/EndValues。即:

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; 
     } 
    } 
    } 
}