我在StringGrid中插入Editbox时遇到问题。我的表单上有一个StringGrid和一个Editbox。编辑框在选定的col和row中显示正常,但我可以在所选单元格中只插入一个数字...有人可以解释我如何在那里放置更多数字吗?
TNX!
//Editbox on change event
void __fastcall TForm3::StringGridEditChange(TObject *Sender)
{
int x,y;
x = Form3->VariableGrid->Col;
y = Form3->VariableGrid->Row;
if (VariableGrid->Col !=2 )
{
VariableGrid->Col = 2;
}
if (VariableGrid->Row <1 )
{
VariableGrid->Row = 1;
ShowMessage("Prevention!");
}
VariableGrid->Cells[VariableGrid->Col][VariableGrid->Row] = StringGridEdit->Text;
StringGridEdit->Visible = false;
VariableGrid->SetFocus();
//StringGrid on selectCell event
void __fastcall TForm3::VariableGridSelectCell(TObject *Sender, int ACol, int ARow,
bool &CanSelect)
{
if(ACol == 2 && ARow>0)
{
TRect R = VariableGrid->CellRect(ACol, ARow);
R.Left += VariableGrid->Left;
R.Right += VariableGrid->Left;
R.Top += VariableGrid->Top;
R.Bottom += VariableGrid->Top;
StringGridEdit->Left = R.Left + 1;
StringGridEdit->Top = R.Top + 1;
StringGridEdit->Width = (R.Right + 1) - R.Left;
StringGridEdit->Height = (R.Bottom + 1) - R.Top;
//Show the editbox
StringGridEdit->Visible = true;
StringGridEdit->SetFocus();
}
CanSelect = true;
}
在C ++ Builder XE2中