Ver Mensaje Individual
  #2  
Antiguo 20-11-2009
_cero_ _cero_ is offline
Miembro
 
Registrado: abr 2007
Posts: 147
Reputación: 18
_cero_ Va por buen camino
Thumbs up

Pues en el DBGrid existe el evento “OnDrawColumnCell” ahí puedes tomar el dato, convertirlo y después volverlo a escribir en la rejilla, como ejemplo te dejo este trozo de código que convierte un valor 1 ó 2 en la frase uno o dos respectivamente, pero solo en la columna 4 (índice 3).
Código:
void __fastcall TFom1::DBGrid1DrawColumnCell(TObject *Sender, const TRect &Rect, int DataCol,
          TColumn *Column, TGridDrawState State)
{
    if (Column->Index==3) {
        switch (QueryTabla->FieldByName("TIPO")->AsInteger) {
            case 0: {
                dgri->Canvas->TextRect(Rect, Rect.Left+2, Rect.Top+2, "Uno");
                break;
            }
            case 1: {
                dgri->Canvas->TextRect(Rect, Rect.Left+2, Rect.Top+2, "Dos");
                break;
            }
        }
    }
}
nos vemos.
Responder Con Cita