Цитата(artsb @ 4.7.2011, 22:32 ) | | А разве две эти опции одновременно нельзя включать? |
Да, нельзя.
Цитата(Нитонисе @ 4.7.2011, 16:39 ) | | Затем, когда состояние стринггрида изменилось, нужно опять переключить опции. Как словить этот момент? |
Вроде бы вот так работает:
| Код | __fastcall TForm2::TForm2(TComponent* Owner) : TForm(Owner) { pSelectedCell.x = pSelectedCell.y = -1; } //--------------------------------------------------------------------------- void __fastcall TForm2::StringGrid1GetEditText(TObject *Sender, int ACol, int ARow, UnicodeString &Value) { pSelectedCell.x = ACol; pSelectedCell.y = ARow; } //--------------------------------------------------------------------------- void __fastcall TForm2::StringGrid1SelectCell(TObject *Sender, int ACol, int ARow, bool &CanSelect) { if((pSelectedCell.x != -1 && pSelectedCell.y != -1) && (pSelectedCell.x != ACol || pSelectedCell.y != ARow)) { pSelectedCell.x = pSelectedCell.y = -1;
StringGrid1->Options = StringGrid1->Options >> goEditing; StringGrid1->Options = StringGrid1->Options << goRowSelect; } } //--------------------------------------------------------------------------- void __fastcall TForm2::StringGrid1DblClick(TObject *Sender) { StringGrid1->Options = StringGrid1->Options >> goRowSelect; StringGrid1->Options = StringGrid1->Options << goEditing; } //---------------------------------------------------------------------------
|
pSelectedCell - это TPoint, закрытый член класса TForm2. |