Sasan
2008-07-26 07:51:01 UTC
Hello,
I create OnTitle click for sorting dbgrid but it has a bug:
If all columns can not seen in grid and user click column that scrolled to
see it, grid sort by that filed also
columns scrolled to first column !
How can prevent from scrolling after sorting ?
/////////////////
// CODE
//---------------------------------------------------------------------------
void __fastcall TForm1::DBGrid1TitleClick(TColumn *Column)
{
bool Order;
AnsiString Str;
TCustomADODataSet * Dataset;
Dataset = dynamic_cast <TCustomADODataSet
*>(Column->Grid->DataSource->DataSet);
Order = Pos(" DESC", Dataset->Sort) == 0 ? true : false;
Order = Pos(Column->Field->FieldName, Dataset->Sort) == 1 ? !Order : Order;
Str = ::Format("%s %s", ARRAYOFCONST((AnsiString(Column->FieldName), Order
? "ASC" : "DESC")));
Dataset->Sort = Str;
}
//---------------------------------------------------------------------------
Kind Regards,
sasan.
I create OnTitle click for sorting dbgrid but it has a bug:
If all columns can not seen in grid and user click column that scrolled to
see it, grid sort by that filed also
columns scrolled to first column !
How can prevent from scrolling after sorting ?
/////////////////
// CODE
//---------------------------------------------------------------------------
void __fastcall TForm1::DBGrid1TitleClick(TColumn *Column)
{
bool Order;
AnsiString Str;
TCustomADODataSet * Dataset;
Dataset = dynamic_cast <TCustomADODataSet
*>(Column->Grid->DataSource->DataSet);
Order = Pos(" DESC", Dataset->Sort) == 0 ? true : false;
Order = Pos(Column->Field->FieldName, Dataset->Sort) == 1 ? !Order : Order;
Str = ::Format("%s %s", ARRAYOFCONST((AnsiString(Column->FieldName), Order
? "ASC" : "DESC")));
Dataset->Sort = Str;
}
//---------------------------------------------------------------------------
Kind Regards,
sasan.