Autor Beitrag
Danny87
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 688

Windows 10 Pro 64bit
Sprachen: HTML, PHP, JavaScript, Delphi || IDE: RAD Studio 10.1 Berlin Starter, WeBuilder
BeitragVerfasst: Fr 23.12.05 10:53 
Ich arbeite momentan an einem Programm, das so aussieht:

user defined image
Ich hab zur demonstration so viele radiobuttons wie möglich aktiviert.



Nun meine Frage:

Wie kann ich, mit möglichst wenig aufwand, testen, welche radiobuttons aktiviert sind und welche nicht?
Die radiobuttons sind immer in einem "Zehnerpaket" auf insgesamt 20 Panels untergebracht (man siehts an den farblichen unterschieden).


Zuletzt bearbeitet von Danny87 am Fr 23.12.05 11:59, insgesamt 1-mal bearbeitet
MisterBum83
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 245
Erhaltene Danke: 2

WIN XP
Delphi 6
BeitragVerfasst: Fr 23.12.05 11:56 
Du hast das ganze doch bestimmt mit RadioGroup immer gemacht, d.h. für jede Reihe von 1 bis 10.
Jetzt kannst du doch pro Reihe immer den ItemIndex (welcher RadioButton gecheckt ist) abfragen:
-1 = keiner ausgewählt
3 = RadioButton4 (fängt bei 0 an zu zählen)

Gruß MisterBum
Danny87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 688

Windows 10 Pro 64bit
Sprachen: HTML, PHP, JavaScript, Delphi || IDE: RAD Studio 10.1 Berlin Starter, WeBuilder
BeitragVerfasst: Fr 23.12.05 11:58 
nein, ich habe jeweils 10 radiobuttons auf ein panel gesetzt.
und das 20 mal.
Limster
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 72


Delphi 5 & 7 Enterprise
BeitragVerfasst: Fr 23.12.05 12:19 
Titel: So
Hi!

machs so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
function GetValueFromPanel(aPanel: TPanel): Integer;
var
  lComponent : TComponent;
  lIndex     : Integer;
  i          : Index;
  lRB        : TRadioButton;
begin
  result := -1;
  lIndex := -1;
  for i := 0 to (aPanel.ComponentCount - 1) do begin
    lComponent := aPanel.Components[i];
    if lComponent.inheritsFrom(TRadioButton) then begin
      inc(lIndex);
      lRB := TRadioButton(lComponent);
      if (lRB.Checked) then begin
        result := lIndex;
        break;
      end;    
    end;
  end;
end;


Aufzupassen ist, dass die Radiobuttons in der Reihenfolge wie von links nach rechts auch erstellt werden,
ansonsten stimmt der zurückgegebene index nicht..

um die reihenfolge zu kontrollieren, einfach auf der Form -> rechte maustaste -> showAsText

und nach den jeweiligen panels suchen und gegebenfalls die reihenfolge der radiobuttons innerhalb des
Panels ändern..

grüsse,
Limbo

Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt
Danny87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 688

Windows 10 Pro 64bit
Sprachen: HTML, PHP, JavaScript, Delphi || IDE: RAD Studio 10.1 Berlin Starter, WeBuilder
BeitragVerfasst: Fr 23.12.05 12:22 
Ich ... ähm,... glaub ich machs dann doch lieber mit radiogroup... ;-)

Ich baue keinen Code ein den ich nicht 100% verstehe.:-D:-D
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Fr 23.12.05 12:38 
Hallo,

mit den Radiobuttons sollen doch Werte von 1 bis 10 eingestellt werden.
Was hältst du denn von TrackBars oder ScrollBars?

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Danny87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 688

Windows 10 Pro 64bit
Sprachen: HTML, PHP, JavaScript, Delphi || IDE: RAD Studio 10.1 Berlin Starter, WeBuilder
BeitragVerfasst: Fr 23.12.05 12:57 
Nichts *grins*, mein Chef hat gesagt, ich solls mit RadioButtons machen