Autor Beitrag
n-regen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 202
Erhaltene Danke: 2



BeitragVerfasst: Mi 10.09.08 12:38 
Hallo!

Ich suche nach einer Komponente, die zwei Spalten anzeigt, die man nicht editieren oder auswählen kann und am Anfang jeder Zeile einen Radiobutton hat.
Für alle die sich nicht vorstellen können, was ich meine, habe ich einen Screenshot montiert.
Gibt es sowas?
Einloggen, um Attachments anzusehen!
Calculon
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 676

Win XP Professional
Delphi 7 PE, Delphi 3 PRO
BeitragVerfasst: Mi 10.09.08 12:44 
Wenn statt Radioboxes auch Checkboxes gehen: TListView

Gruß
--

_________________
Hallo Mutti
n-regen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 202
Erhaltene Danke: 2



BeitragVerfasst: Mi 10.09.08 13:12 
Das ist zwar schonmal ganz gut, aber ich hab im Moment noch keine Idee, wie ich verhidern soll, das zwei Checkboxen aktivert werden.
Auf jeden Fall mal danke für den Hinweis.
Calculon
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 676

Win XP Professional
Delphi 7 PE, Delphi 3 PRO
BeitragVerfasst: Mi 10.09.08 13:25 
Also mit normalen Checkboxes kann man das so machen

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TfrmMain.CheckBox1Click(Sender: TObject);
begin
  if CheckBox1.Checked then
    CheckBox2.Checked := FALSE
end;

procedure TfrmMain.CheckBox2Click(Sender: TObject);
begin
  if CheckBox2.Checked then
    CheckBox1.Checked := FALSE
end;

Gibt aber bestimmt bessere Möglichkeiten...

Gruß
--

_________________
Hallo Mutti
n-regen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 202
Erhaltene Danke: 2



BeitragVerfasst: Mi 10.09.08 13:37 
Ich weiß aber beim Programmieren noch nicht, wieviele Einträge (und somit auch Checkboxes) ich haben werde.
Das funktioniert also nicht.
P-A-L
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Mi 10.09.08 13:44 
user profile iconn-regen hat folgendes geschrieben:
Ich weiß aber beim Programmieren noch nicht, wieviele Einträge (und somit auch Checkboxes) ich haben werde.
Das funktioniert also nicht.


Du könntest ja aber eine Schleife vom ersten bis zum letzten Element durchlaufen lassen, in welcher alle Häkchen ausser dem aktuellen gelöscht werden...

Sicher, dass die Komponente keine "multiplechoice:boolean" property hat?
n-regen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 202
Erhaltene Danke: 2



BeitragVerfasst: Mi 10.09.08 15:37 
Ja, ich bin mir sicher.
Ich probiere mal, ob ich eine passende Schleife zustande bringe.

EDIT: Eine Möglichkeit ist folgende Prozedur bei ListView.OnClick:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
var
i,iss:integer;
begin
 iss := 0;
 for i := 0 to (listview1.Items.Count - 1) do begin
  if listview1.Items.Item[i].Checked
  then inc(iss);
 end;
 if iss > 1 then begin
  for i := 0 to (listview1.Items.Count - 1) do begin
   if listview1.Items.Item[i].Checked = sel[i]
   then listview1.Items.Item[i].Checked := false;
  end;
 end;
 setlength(sel, listview1.Items.Count-1);
 for i := 0 to (listview1.Items.Count - 1) do begin
  sel[i] := listview1.Items.Item[i].Checked;
 end;
end;


Man sollte außerdem bei OnKeyUp auf diese Prozedur verweisen, wenn VK_SPACE gedrückt wird.
Ferner muss man noch ein array of boolean namens "sel" global festlegen.
Calculon
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 676

Win XP Professional
Delphi 7 PE, Delphi 3 PRO
BeitragVerfasst: Mi 10.09.08 18:13 
Total ungetestet (frei nach user profile iconP-A-L's Vorschlag):

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
  for i := 0 to ListView1.Items.Count - 1 do
    begin
      if i <> ListView.ItemIndex then  // oder ListView.Items.ItemIndex
        ListView1.Items.Item[i].Checked := FALSE;   
    end;

Gruß
--

_________________
Hallo Mutti
n-regen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 202
Erhaltene Danke: 2



BeitragVerfasst: Do 11.09.08 08:49 
Ich habe das Problem mit dem oben genannten Quelltext gelöst.
Dein Vorschlag würde auch nicht funktionieren, da man die Checkbox aktivieren kann, ohne das Item zu markieren.
Auf jeden Fall Danke an alle, die zur Lösung beigetragen haben.
Calculon
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 676

Win XP Professional
Delphi 7 PE, Delphi 3 PRO
BeitragVerfasst: Do 11.09.08 09:00 
user profile iconn-regen hat folgendes geschrieben:
[..] Dein Vorschlag würde auch nicht funktionieren, da man die Checkbox aktivieren kann, ohne das Item zu markieren.
Auf jeden Fall Danke an alle, die zur Lösung beigetragen haben.

Und wenn du dir die angehakte Zeile merkst (z.B. in irgendeinem Tag oder in 'ner globalen Variable) und in meinem Code dann ListView.ItemIndex durch diesen Speicher ersetzt?

Gruß
--

_________________
Hallo Mutti