AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

ListBox

Ein Thema von value is NULL · begonnen am 6. Jun 2014 · letzter Beitrag vom 8. Jun 2014
 
Jumpy

Registriert seit: 9. Dez 2010
Ort: Mönchengladbach
1.740 Beiträge
 
Delphi 6 Enterprise
 
#21

AW: ListBox

  Alt 6. Jun 2014, 11:00
Nur sinngemäß, da ich gerade kein Delphi offen habe, geht bestimmt auch einfacher:

Delphi-Quellcode:
type
  TLBColor=class
    public
     Color:TColor;
  end;


//Item zur Liste hinzufügen:
procedure TForm1.Button1Click(Sender: TObject);
var t:TLBColor;
begin
  t:=TLBColor.Create;
  t.Color:=clWhite;
  Listbox1.AddItem('foo',t);
end;

//in deiner Prüffunktion
while i < Form1.ListBox1.Count do begin
    userId := sqlst.query('select id from user_ where username = '''+Form1.listbox1.Items[i]+'''');
    //user not found
    if userId = 'then //Change Color of current line - cLYellow
      TLBColor(Listbox1.Items.Objects(i)).Color:=clRed;
    i := i + 1;
end;



procedure TForm1.ListBox1DrawItem
    (Control: TWinControl; Index: Integer;
    Rect: TRect; State: TOwnerDrawState) ;
 var
    myColor: TColor;
    myBrush: TBrush;
 begin
    myBrush := TBrush.Create;
    with (Control as TListBox).Canvas do
    begin
      myColor := TLBColor(Listbox1.Items.Objects(index)).Color;
      myBrush.Style := bsSolid;
      myBrush.Color := myColor;
      Windows.FillRect(handle, Rect, myBrush.Handle) ;
      Brush.Style := bsClear;
      TextOut(Rect.Left, Rect.Top,
              (Control as TListBox).Items[Index]) ;
      MyBrush.Free;
    end;
 end;
Ralph
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:14 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz