Autor Beitrag
gd0123456
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: So 03.02.13 13:51 
Hallo,

hab mal eine Frage, ist es möglich die checkbox in ein Listitem zu bekommen? also bei jedem Eintrag soll eine checkbox mitangezeigt werden.

Meine Idee war es ja, den parent der checkbox den parent vom listitem zuzweisen, damit entsteht so eine Art Container (so verstehe ich es, funktioniert mit dem panel ja auch):

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
 
  var 
    c: tcheckbox;
    t: tlistitem;
  begin
 
    c:= Tcheckbox.Create(nil);
    c.Parent := self;
    c.visible := true;
    c.Caption := 'test';
    c.ParentColor := true;

    t:= listview1.Items.Add;
    t.Caption := 'get';
    c.Parent := t; //<-- geht aber leider nicht,es geht nur listview

  end;


Nur leider kann ich der checkbox nur dem parent vom Listview zuweisen.
Gibt es eine andere Möglichkeit wie ich eine checkbox bzw. mehere in das Listitem bekomme?

Danke für eure Hilfe


Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am So 03.02.2013 um 13:52
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: So 03.02.13 14:27 
TListView.Checkboxes auf true zu stellen sollte genügen.
gd0123456 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: So 03.02.13 14:41 
Ja das ist mir schon klar, aber dann kommen die Checkboxen ja in der ersten Spalte, möchte es aber z.B. in der 3 Spalten haben.
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: So 03.02.13 14:44 
Da bleibt wohl nur Selberzeichnen (oder eine andere Komponente nehmen, die das schon von sich aus kann, z.B. das NextGrid).
gd0123456 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: So 03.02.13 14:53 
Ach schade, also eine schnellere oder leichtere Möglichkeit gibt es nicht? außer jetzt selbst zeichen oder das "nextgrid"?
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: So 03.02.13 14:55 
Is nunmal so: wer etwas vom Standard abweichendes möchte, der muss selbst Hand anlegen.
gd0123456 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: So 03.02.13 15:02 
Ok und eine Frage noch,

ich kann es ja auch so machen dass die checkbox über das Listitem angezeigt wird. Allerdings habe ich dann das Problem dass die checkbox also da wo der Text von der checkbox steht die Hintergrundfarbe weiß hat, gibt es da eine Möglichkeit die Farbe zu ändern?
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: So 03.02.13 15:08 
Setz doch einfach die Breite so, dass nur die eigentliche Box zu sehen ist. Wobei das Selbstzeichnen direkt in der ListView IMO die bessere Alternative wäre, nur habe ich da aktuell keine Idee, wie man die Checkbox dann auswerten soll.
gd0123456 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: So 03.02.13 15:14 
Danke für deine Hilfe, hab es jetzt genau so gemacht. Das mit dem Auswerten ist dann weniger das Problem. Danke schön.