Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   C++ Builder (https://www.clubdelphi.com/foros/forumdisplay.php?f=13)
-   -   Problemas en StringGrid (https://www.clubdelphi.com/foros/showthread.php?t=85537)

eennzzoo 28-03-2014 21:36:21

Problemas en StringGrid
 
Hola tengo un problema con el tema de los colores en un StringGrid

Con este codigo pinto la primer fila que esta fija. Pero yo antes de este codigo escribi un titulo para la primer posicion con cells [0][0]="titulo" pero no aparece lo que escribi para esa fila. A menos que saque el siguiente codigo.
Código:

void __fastcall TfPeliculas::StringGrid1DrawCell(TObject *Sender, int ACol,
      int ARow, TRect &Rect, TGridDrawState State)
{
        if( State.Contains(gdFixed) )
 {
 StringGrid1->Canvas->Brush->Color = static_cast<TColor>(RGB(255, 155, 0));
 StringGrid1->Canvas->Font->Style = TFontStyles() << fsBold;
 StringGrid1->Canvas->Font->Color = static_cast<TColor>(RGB(250, 245, 135));

 StringGrid1->Canvas->Rectangle(Rect);

 }


ecfisa 28-03-2014 22:10:34

Hola eennzzoo.

Te falta "reescribir" el texto:
Código:

void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
      int ARow, TRect &Rect, TGridDrawState State)
{
  if (State.Contains(gdFixed)) {
    TCanvas *CV = static_cast <TCanvas*> (StringGrid1->Canvas);
    CV->Brush->Color = (TColor)(RGB(255,155,0));
    CV->Font->Style = TFontStyles() << fsBold;
    CV->FillRect(Rect);
  CV->TextOut(Rect.Left+1,Rect.top+1,StringGrid1->Cells[ACol][ARow]);
  }
}

Saludos :)

eennzzoo 28-03-2014 22:13:14

Cita:

Empezado por ecfisa (Mensaje 474508)
Hola eennzzoo.

Te falta "reescribir" el texto:
Código:

void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
      int ARow, TRect &Rect, TGridDrawState State)
{
  if (State.Contains(gdFixed)) {
    TCanvas *CV = static_cast <TCanvas*> (StringGrid1->Canvas);
    CV->Brush->Color = (TColor)(RGB(255,155,0));
    CV->Font->Style = TFontStyles() << fsBold;
    CV->FillRect(Rect);
  CV->TextOut(Rect.Left+1,Rect.top+1,StringGrid1->Cells[ACol][ARow]); // <- aqui
  }
}

Saludos :)

Gracias faltaba el canvas antes del textout.



La franja horaria es GMT +2. Ahora son las 16:42:04.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi