Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   C++ Builder (https://www.clubdelphi.com/foros/forumdisplay.php?f=13)
-   -   Cambiar fuente en el caption de columnas de un Listview (https://www.clubdelphi.com/foros/showthread.php?t=85043)

Angel.Matilla 17-01-2014 10:50:06

Cambiar fuente en el caption de columnas de un Listview
 
¿Se puede cambiarla fuente sólo del caption de un columna de un TListView? Para ponerlo, por ejemplo, en negrilla.

ecfisa 17-01-2014 13:45:56

Hola Angel.

Un ejemplo:
Código:

int BoldColumn = -1;

// ajustar ListView
void __fastcall TForm1::FormCreate(TObject *Sender)
{
 ListView1->OwnerDraw = false;
 ListView1->ViewStyle = vsReport;
}

// tratar columna 0
void __fastcall TForm1::ListView1CustomDrawItem(TCustomListView *Sender,
  TListItem *Item, TCustomDrawState State, bool &DefaultDraw)
{
  if (BoldColumn == 0)
  Sender->Canvas->Font->Style = TFontStyles() << fsBold;
}

// tratar otras columnas
void __fastcall TForm1::ListView1AdvancedCustomDrawSubItem(
  TCustomListView *Sender, TListItem *Item, int SubItem,
  TCustomDrawState State, TCustomDrawStage Stage, bool &DefaultDraw)
{
 if (SubItem != 0 && SubItem == BoldColumn)
    Sender->Canvas->Font->Style = TFontStyles() << fsBold;
}

// aplicar negrita a columna  (0..n-1)
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  BoldColumn = StrToIntDef(Edit1->Text, -1);
  ListView1->Invalidate();
}

Saludos :)

FideRosado 21-01-2014 17:35:24

respuesta
 
hola amigos , pueden poner este ejemplo para delphi 7 por favor..

ecfisa 21-01-2014 18:14:24

Hola FideRosado.

Código Delphi [-]
var
  BoldColumn : Integer = -1;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ListView1.OwnerDraw := false;
  ListView1.ViewStyle := vsReport;
end;

procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
  Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
  if (BoldColumn = 0) then
    with Sender.Canvas.Font do
      Style := Style + [fsBold];
end;

procedure TForm1.ListView1AdvancedCustomDrawSubItem(
  Sender: TCustomListView; Item: TListItem; SubItem: Integer;
  State: TCustomDrawState; Stage: TCustomDrawStage;
  var DefaultDraw: Boolean);
begin
  if (SubItem <> 0) and (SubItem = BoldColumn) then
   with Sender.Canvas.Font do
     Style := Style + [fsBold];
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  BoldColumn := StrToIntDef(Edit1.Text, -1);
  ListView1.Invalidate();
end;

Saludos :)


La franja horaria es GMT +2. Ahora son las 08:46:11.

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