C++Builder StringGrid 控件的事件
StringGrid控件有没有编辑完一个格子,并且在退出编辑时触发的事件。我想编辑各自并且读取到新写入格子的数据!,谢谢指教!!!
[解决办法]
里面放个edit?退出时在edit exit当中响应事件,
[解决办法]
我有段代码 不知道是不是你需要的功能 ,先在窗体当中放一个edit
[code=C/C++][/code]
void __fastcall TForm1::StringGrid1SelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
TStringGrid *sg = dynamic_cast<TStringGrid*>(Sender);
if (!sg)
return;
sg->Perform(WM_CANCELMODE, 0, 0);
TRect R = sg->CellRect(ACol, ARow);
TPoint org = ScreenToClient(sg->ClientToScreen(TPoint(R.Left, R.Top)));
Edit1->SetBounds(org.x, org.y, R.right - R.left, StringGrid1->RowHeights [sg->Row]);
Edit1->Show();
Edit1->BringToFront();
Edit1->SetFocus();
Edit1->Text = "";
Edit1->Text = StringGrid1->Cells [ACol][ARow];
Edit1->SelectAll();
}
//---------------------------------------
void __fastcall TForm1::Edit1Exit(TObject *Sender)
{
if(StringGrid1->Col<17)
{
if(Edit1->Text=="")
StringGrid1->Cells [StringGrid1->Col][StringGrid1->Row] = "00" ;
else if(Edit1->Text.Length()==1)
StringGrid1->Cells [StringGrid1->Col][StringGrid1->Row] = "0"+Edit1->Text;
else
StringGrid1->Cells [StringGrid1->Col][StringGrid1->Row] = Edit1->Text ;
Edit1->Visible = false;
}
}