1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
//evenement Click sur titre de Colonne (OnTileClick)
void __fastcall TForm1::DBGrid1TitleClick(TColumn *Column)
{
try{
AnsiString SortExpr ="";
if(Column->Field->Tag==0){ //tag conserve l'etat de tri (ascendant /descendant).
SortExpr = Column->FieldName+" ASC";
Column->Field->Tag=1;
}else {
SortExpr = Column->FieldName+" DESC";
Column->Field->Tag=0;
}
// avec TADOQuery
// ((TADOQuery*)(Column->Field->DataSet))->Sort = SortExpr;
// avec TADOTable
((TADOTable*)(Column->Field->DataSet))->Sort = SortExpr;
}catch(Exception &e){}
}
//---------------------------------------------------------------------------
//affichage curseur main evenement OnMouseMove de TDBGrid
void __fastcall TForm1::DBGrid1MouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
TDBGrid * Grid = (TDBGrid*)Sender;
TGridCoord coord = Grid->MouseCoord(X,Y);
if( coord.Y == 0 ) Grid->Cursor =crHandPoint;
else Grid->Cursor=crDefault;
}
//--------------------------------------------------------------------------- |
Partager