Autor Beitrag
Roboman
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 115

WinXP
Delphi 2005 Prof.; Delphi 6 Prof.; C++; C; Basic
BeitragVerfasst: Di 27.06.06 08:19 
Servus Leute,
hab ein kleines Problem, wohl eher ein Brett vor dem Kopf. Naja. Ich möchte in einem Editfeld Zahlem mit Kommawerten darstellen, so z. B. 10,05 und diese mit einem UpDown-Button hoch und runter zählen lassen mit ner Auflösung von 0,01. Aber wie kann ich das realisieren, der UpDown-Button kann doch nur Integerzahlen.

Habt ihr da ne Lösung oder ne Komponente die das realisieren kann?

Ich danke euch schon jetzt ganz herzlich für jede Antwort.

Wünsche noch einen schönen Tag.
digi_c
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1905

W98, XP
D7 PE, Lazarus, WinAVR
BeitragVerfasst: Di 27.06.06 11:31 
Am saubersten wäre eine eigene Komponente. Vielleicht gibt es die sogarn in der JEDI VCL oder bei www.torry.net schon.

Ansonsten leite doch eine eigene ab so wie ein TSpinEdit. Dafür bräuchtest du einen internen Wert z.B. fValue:real; den du beim drücken der Knöpfe um 0,01 veränderst und dann im Edit anzeigst. dann nimmst du noch im Edit(oder TMaskedEdit) Erweiterungen vor, das auch dieses fValueverändert und Fehleingaben abfängt.
aim65
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 312

Win 9x, Win XP
Delphi 3pro, 7PE
BeitragVerfasst: Di 27.06.06 12:26 
Geht ganz einfach, hier ein Beispiel 8) :
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.UpDown1Click(Sender: TObject; Button: TUDBtnType);
var  wert: Single;
begin
  if Button =btnext then    //Range (max & min)im OI nicht vergessen!
    wert := StrToFloat(Edit1.Text) + 0.01
  else
    wert := StrToFloat(Edit1.Text) - 0.01;
  Edit1.Text := FloatToStrF(wert,fffixed,6,2);
end;

Gehe davon aus, daß du Edit1 mit einer Start-Zahl initialisierst. Im OI mußt du beim UpDownButton noch "Min" und "Max" entsprechend setzen (z.B. -1000,1000). das ergibt den maximalen Bereich deiner Schritte. Die Schrittweite definiertst du in der Routine (oben z.B. deine 0,01).
digi_c
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1905

W98, XP
D7 PE, Lazarus, WinAVR
BeitragVerfasst: Di 27.06.06 14:29 
Ach verdammt "Mittagsstund hat Blei im Mund" :roll:
Roboman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 115

WinXP
Delphi 2005 Prof.; Delphi 6 Prof.; C++; C; Basic
BeitragVerfasst: Fr 30.06.06 12:50 
Hallo Leute,
danke für euere Antworten, war mal kurze Zeit im Krankenhaus und musste meinem Programmiererdrang mal einhalt gewähren und mich um meine Gesundheit kümmern.

Werde die Sachen sofort mal ausprobieren. Danke für eure Hilfe.
Roboman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 115

WinXP
Delphi 2005 Prof.; Delphi 6 Prof.; C++; C; Basic
BeitragVerfasst: Fr 30.06.06 16:17 
Danke aim65 für deinen Lösungsvorschlag. Hat zwar was gedauert bis das ich meinen Fehler gefunden hatte, man darf dann nicht das Edit1 mit dem UpDown "Associate" nicht aktivieren.

Vielen Dank
aim65
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 312

Win 9x, Win XP
Delphi 3pro, 7PE
BeitragVerfasst: Sa 01.07.06 12:01 
Hab's erst heute gesehen.
Ohne "Associate" hängt UpDownButton "frei in der Luft" und kann mit beliebigen Aktionen verknüpft werden. Das ergibt eine große Flexibilität.
Associate habe ich noch nie benutzt (ist mir ehrlich gesagt noch gar nicht aufgefallen) :lol: