Hello there,
Recently i try to get deeper into TAdvStringGrid, So i added some combobox into cells:
void __fastcall TfrmSurveyEditor::grdHeaderGetEditorProp(TObject *Sender, int ACol, int ARow, TEditLink *AEditLink)
{
if(ARow>0 && ACol>0 && Visible) {
grdHeader->ClearComboString();
grdHeader->AddComboString("Pole tekstowe");
grdHeader->AddComboString("Wartość numeryczna");
grdHeader->AddComboString("Wyb?r liczbowy (1-5)");
grdHeader->SetComboSelection(0);
// grdHeader->Combobox->ItemIndex=0;
//grdHeader->Cells[ACol][ARow] = "Pole tekstowe";
}
}
And:
void __fastcall TfrmSurveyEditor::grdHeaderGetEditorType(TObject *Sender, int ACol, int ARow, TEditorType &AEditor)
{
if(ARow>0 && ACol>0 && Visible) {
AEditor = edComboList;
//grdHeader->SetComboSelection(0);
//grdHeader->Cells[ACol][ARow] = "Pole tekstowe";
}
}
The problem is, the default value "Pole tekstowe" (or any other) is not visible until i click on given cell or set it's value explicitly via:
grdHeader->Cells[x][y] = "Pole Tekstowe";
How to "force" it to display values all the time from beginning ?
Kind regards
Any1 ?
Also: what is
ASG->CellProperties[x][y]->CellObject ?
Can i use it as "tag" ?
What does it do ?
1. To set the default value, set it from grid.OnGetEditText
2. To store information with cells, please use grid.Objects[col,row]:TObject;
What i am getting after compile is:
After i click on the cell:
What i want to achieve:

LInk to minimal project:
http://waldek.ceron.pl/tms/ASGTest.zip
And source:
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::grdHeaderGetEditorProp(TObject *Sender, int ACol, int ARow, TEditLink *AEditLink)
{
if(ARow>0 && ACol>0 && Visible) {
grdHeader->ClearComboString();
grdHeader->AddComboString("Pole tekstowe");
grdHeader->AddComboString("Wartość numeryczna");
grdHeader->AddComboString("Wybór liczbowy (1-5)");
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::grdHeaderGetEditorType(TObject *Sender, int ACol, int ARow, TEditorType &AEditor)
{
if(ARow>0 && ACol>0 && Visible) {
AEditor = edComboList;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::grdHeaderGetEditText(TObject *Sender, int ACol, int ARow, UnicodeString &Value)
{
if (Value.IsEmpty()) {
Value="Pole tekstowe";
}
}
//---------------------------------------------------------------------------
How to get desired behaviour ?
Just specifying the combobox as inplace editor will not preset the grid cell values.
If you want to do this, you'd need to preset programmatically the grid cell values and you can do this with grid->Cells[col][row]:string;