Ja sam cijelu stvar postavio ovako:
Code:
void __fastcall TFGlavni::DBGrid1TitleClick(TColumn *Column)
{
static index = 1;
if(index == 0)
{
if(Column->Field->Index == 1) {
DM1->TProjekt->IndexFieldNames = "Naziv ASC";
index = 1;
}
if(Column->Field->Index == 2) {
DM1->TProjekt->IndexFieldNames = "BrojProjekta ASC";
index = 2;
}
if(Column->Field->Index == 3) {
DM1->TProjekt->IndexFieldNames = "ArhivskiBroj ASC";
index = 3;
}
if(Column->Field->Index == 4) {
DM1->TProjekt->IndexFieldNames = "GodinaIzrade ASC";
index = 4;
}
if(Column->Field->Index == 5) {
DM1->TProjekt->IndexFieldNames = "Investitor ASC";
index = 5;
}
}
else
{
if(index == 1){
DM1->TProjekt->IndexFieldNames = "Naziv DESC";
index = 0;
}
if(index == 2){
DM1->TProjekt->IndexFieldNames = "BrojProjekta DESC";
index = 0;
}
if(index == 3){
DM1->TProjekt->IndexFieldNames = "ArhivskiBroj DESC";
index = 0;
}
if(index == 4){
DM1->TProjekt->IndexFieldNames = "GodinaIzrade DESC";
index = 0;
}
if(index == 5){
DM1->TProjekt->IndexFieldNames = "Investitor DESC";
index = 0;
}
}
}
U početku sortirano je po prvom stupcu (ASC), a dalje ako se na isti stupac klikne onda se sortira po DESC. I sve radi osim tog 4. stupca...
Sada sam stavio dva TButtona koji zasebno rade ASC i DESC nad tim stupcem i to radi bez greške, no u ovom gore kodu neće.. a svi ostali stupci se sortiraju bez problema...