Club Builder - Foros de discusión Club Builder
Foro de C++Builder en español
 
 FAQFAQ   BuscarBuscar   MiembrosMiembros   Grupos de UsuariosGrupos de Usuarios   RegistrarseRegistrarse 
 PerfilPerfil   Entra para ver tus mensajes privadosEntra para ver tus mensajes privados   EntrarEntrar 

Color de las Lineas de la Grilla del StringGrid

 
Publicar nuevo tema   Responder al tema    Foros de discusión -> Consultas
Ver tema anterior :: Ver tema siguiente  
Autor Mensaje
Mensaje    Asunto: Color de las Lineas de la Grilla del StringGrid Responder citando

Alguien sabe como cambiar el color de las líneas de un TStringGrid, desde ya muchas gracias
Volver arriba
Mensaje    Asunto: Responder citando

[url]
https://cppbuilder.es/viewtopic.php?t=3661
[/url]
Volver arriba
Mensaje    Asunto: Responder citando

El link que me envia, solo cambia el color de las celdas(Rectangulos), pero lo que ando buscando es el color que sepata a esos rectangulos (color de la grilla)
Volver arriba
Mensaje    Asunto: Responder citando

He buscado por todos lados y no logro encontrar la forma de cambiar las lineas del contorno en un stringgrid.

estoy tratando de dibujar una vista aerea de un almacen y necesito que algunas celdas tengan bordes y otras no..


de antemano Gracias
Volver arriba
Ver perfil de usuario Enviar mensaje privado
Mensaje    Asunto: Responder citando

Retomo el Hilo por que tengo la misma duda..Modificar el color del contorno de un StringGrid.. alguien ha dado con la solucion desde entonces

Gracias
Volver arriba
Ver perfil de usuario Enviar mensaje privado
Mensaje    Asunto: Responder citando

Código:

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  StringGrid3->GridLineWidth=0;
  StringGrid3->Ctl3D=false;
  StringGrid3->Cells[1][1] = "Club";
  StringGrid3->Cells[2][2] = "Builder";
  StringGrid3->Cells[3][3] = "C++";
  StringGrid3->Cells[4][4] = "Builder";
}
//---------------------

void __fastcall TForm1::StringGrid3DrawCell(TObject *Sender, int ACol,
      int ARow, TRect &Rect, TGridDrawState State)
{

   TRect r(Rect);
   StringGrid3->Canvas->FillRect(r);
   StringGrid3->Canvas->Brush->Style = bsClear;
   DrawText(StringGrid3->Canvas->Handle, StringGrid3->Cells[ACol][ARow].c_str(),
            StringGrid3->Cells[ACol][ARow].Length(), &Rect,
            DT_CENTER | DT_VCENTER | DT_SINGLELINE );

   TCanvas* canvas = StringGrid3->Canvas;

    if (StringGrid3->Cells[ACol][ARow] == "Builder")   {
      canvas->Pen->Color = clRed;
      canvas->Rectangle(Rect);
    }
    else if (StringGrid3->Cells[ACol][ARow] == "C++")  {
      canvas->Pen->Color = clBlue;
      canvas->Rectangle(Rect);
    }
   else if (StringGrid3->Cells[ACol][ARow] == "Club") {
      canvas->Pen->Color = clLime;
      canvas->Rectangle(Rect);
   }
}
Volver arriba
Ver perfil de usuario Enviar mensaje privado
Mensaje    Asunto: Responder citando

Código:

void __fastcall TForm1::StringGrid3DrawCell(TObject *Sender, int ACol,
      int ARow, TRect &Rect, TGridDrawState State)
{
  TCanvas* canvas = StringGrid3->Canvas;

  if (State.Contains(gdSelected))  {
    canvas->Brush->Color = clBlack;
    canvas->Pen->Color = clYellow;
    canvas->Font->Color = clLime;
    canvas->Rectangle(Rect);
  }
///////////////////////////////////////////////////////////////////

  TRect r(Rect);
  StringGrid3->Canvas->FillRect(r);
  StringGrid3->Canvas->Brush->Style = bsClear;
  DrawText(StringGrid3->Canvas->Handle, StringGrid3->Cells[ACol][ARow].c_str(),
            StringGrid3->Cells[ACol][ARow].Length(), &Rect,
            DT_CENTER | DT_VCENTER | DT_SINGLELINE );

///////////////////////////////////////////////////////////////////

   if (StringGrid3->Cells[ACol][ARow] == "Builder")   {
    canvas->Pen->Color = clRed;
    canvas->Rectangle(Rect);
    }
   else if (StringGrid3->Cells[ACol][ARow] == "C++")  {
    canvas->Pen->Color = clBlue;
    canvas->Rectangle(Rect);
    }
   else if (StringGrid3->Cells[ACol][ARow] == "Club") {
    canvas->Pen->Color = clLime;
    canvas->Rectangle(Rect);
    }
}
Volver arriba
Ver perfil de usuario Enviar mensaje privado
Mensaje    Asunto: Responder citando

Muchas GRACIAS Felip.
Volver arriba
Ver perfil de usuario Enviar mensaje privado
Mensaje    Asunto: Responder citando

Código:

__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
    // remove the normal division lines
    StringGrid1->Options = StringGrid1->Options >> goVertLine;
    StringGrid1->Options = StringGrid1->Options >> goHorzLine;
}


void DrawPartRect(HDC Hdc, TRect Rect)
{
    POINT P[3];
    P[0] = Point(Rect.Left, Rect.Bottom);
    P[1] = Point(Rect.Right, Rect.Bottom);
//    P[2] = Point(Rect.Right, Rect.Top);
    P[2] = Point(Rect.Right, Rect.Top-1);

    Polyline(Hdc, P, 3);
}


void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, long Col, long Row,
    TRect &Rect, TGridDrawState State)
{
    // if it's a fixed row (headers)
    if (State.Contains(gdFixed))
    {
        StringGrid1->Canvas->Brush->Color = clBtnFace;
        StringGrid1->Canvas->Font->Color = clWindowText;
        StringGrid1->Canvas->FillRect(Rect);
        Frame3D(StringGrid1->Canvas, Rect, clBtnHighlight, clBtnShadow, 1);
        return;
    }


     // if the cell is selected
    else if (State.Contains(gdSelected))
    {
        StringGrid1->Canvas->Pen->Color = clGray;
        StringGrid1->Canvas->Brush->Color = clHighlight;
        StringGrid1->Canvas->Font->Color = clHighlightText;
    }


    // if normal
    else
    {
        StringGrid1->Canvas->Pen->Color = clGray;
        StringGrid1->Canvas->Brush->Color = StringGrid1->Color;
        StringGrid1->Canvas->Font->Color = StringGrid1->Font->Color;
    }
    StringGrid1->Canvas->FillRect(Rect);


// ================================================================
    // change the line color to blue for example
    TColor OldColor = StringGrid1->Canvas->Pen->Color;
    StringGrid1->Canvas->Pen->Color = clBlue;
    DrawPartRect(StringGrid1->Canvas->Handle, Rect);
    StringGrid1->Canvas->Pen->Color = OldColor;
// ================================================================   


    AnsiString text = StringGrid1->Cells[Col][Row];
    StringGrid1->Canvas->TextRect(Rect, Rect.Left, Rect.Top, text);
}



fuente: http://www.codenewsfast.com/cnf/article/0/permalink.art-ng319q4022
Volver arriba
Ver perfil de usuario Enviar mensaje privado
Mostrar mensajes de anteriores:   
Cambiar a:  
No puedes publicar temas nuevos en este foro
No puedes responder a temas en este foro
No puedes editar tus mensajes en este foro
No puedes borrar tus mensajes en este foro
No puedes votar en las encuestas de este foro


Hosting WordPress Indedmedia desde 3,99 €
© 2002–2026 Club Builder · Funciona con phpBB.