TStringGrid OnDrawCell Problem

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #34707
    JCSF
    Participant

    7.3.4.

    I put a TStringList in Frame.

    I put my Frame1 in Form1.

    My TStringGrid OnDrawCell don´t work.

    Code:
    procedure TFrame1.listaDrawCell(Sender: TObject; ACol, ARow: Integer;
    Rect: TRect; State: TGridDrawState);
    var
    texto : string;
    largurat, largurac : integer;
    begin
    if aCol = 7 then
    with (Sender as TStringGrid) do
    begin
    TStringGrid(Sender).Canvas.FillRect(Rect);
    Form1.sAlphaImageList1.Draw(Canvas, Rect.Left, Rect.Top, 3);
    end;

    { If (lista.Cells[7, aRow] = '-') Then
    Begin
    with (Sender as TStringGrid) do
    begin
    Canvas.FillRect(Rect);
    Form1.sAlphaImageList1.Draw(Canvas, Rect.Left, Rect.Top, 3);
    end
    end; }

    If Not (gdFixed in State) Then
    Begin
    If (ARow Mod 2) = 0 Then
    TStringGrid(Sender).Canvas.Brush.Color:= cl3DLight
    Else
    TStringGrid(Sender).Canvas.Brush.Color:= clscrollbar;//$00EEEEEE;
    TStringGrid(Sender).Canvas.FillRect(Rect);
    if (gdselected in state) then
    begin
    TStringGrid(Sender).Canvas.Brush.Color:= clMaroon;
    end
    else
    TStringGrid(Sender).Canvas.Font.Color:= clBlack;

    TStringGrid(Sender).Canvas.TextOut(Rect.Left + 2, Rect.Top + 2,
    TStringGrid(Sender).Cells[ACol, ARow]);
    texto := lista.Cells[ACol, ARow];
    largurat := TStringGrid(Sender).Canvas.TextWidth(texto) div 2;
    largurac := TStringGrid(Sender).ColWidths[ACol] div 2;
    TStringGrid(Sender).Canvas.FillRect(Rect);
    TStringGrid(Sender).Canvas.TextOut(Rect.Left+largurac-largurat,Rect.Top, texto);

    if (Acol = 7) and (ARow > 0) then
    if Lista.Cells[7,ARow] = '.' then
    Form1.sAlphaImageList1.Draw(TStringGrid(Sender).Canvas, Rect.Left+4, Rect.Top+4, 3);
    end;
    end;

    stringgrid.png

    The last column have to receive a image.

    Why? It´s a bug?

    I really need help.

    Thanks xD

    #46398
    JCSF
    Participant

    If i try to retrieve info from Cell this don´t work too!!!

    ShowMessage(Lista.Cells[5, Lista.Row]); in OnDblClick don´t word too.

    Plsss i need help!!! :a1:

    #46402
    mol
    Participant

    Have you tried to put the sImagelist onto Frame1 instead of the main form?

    #46403
    JCSF
    Participant

    Thanks.

    But now i´m using sTListView and now i have a new problem. :a8:

    How to put a image in collumns?

    CustomDrawSubItem

    Code:
    var
    I, K : Integer;
    X : String;
    begin
    for I := 0 to Lista.Items.Count -1 do
    begin
    for K := 0 to Lista.Items.SubItems.Count -1 do
    begin
    If Lista.Items.SubItems[6] = 'X' Then
    Item.ImageIndex := 0;
    end;
    end;
    end;

    Error: List index out of bounds(6). 🙁

    I want to put a image when find X.

    Thanks for all!

    #45966
    JCSF
    Participant

    Solution:

    Code:
    procedure TFrame1.ListaCustomDrawSubItem(Sender: TCustomListView;
    Item: TListItem; SubItem: Integer; State: TCustomDrawState;
    var DefaultDraw: Boolean);
    Var
    I : Integer;
    Begin
    For I := 0 to Item.SubItems.Count -1 Do
    Begin
    If Item.SubItems = 'S' Then
    Begin
    Item.SubItems[5] := '';
    Item.SubItemImages[5] := 0;
    End;
    End;
    End;
    #46436
    Support
    Keymaster

    Hello

    Your problem is solved already?

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.