![]() |
Re: Logisches problem
Wenn
ComboBox4.Items.IndexOf(ComboBox4.Text) = 1 Then dann den Rest ausfüren, ansonsten Combobox4.Items.Add(ComboBox4.Text); und dann erst den Rest ausfüren. Danke nochmal für die Tips :thumb: |
Re: Logisches problem
Zitat:
überprüfe einfach ob es <> -1 ist |
Re: Logisches problem
Hallo Sascha,
Zitat:
Delphi-Quellcode:
In Fabians Code aus Beitrag #10 ist der Fehler nicht enthalten.
for x:= 0 to StringGrid1.ColCount-1 do
begin for y:= 0 to StringGrid1.RowCount-1 do begin Vertrpl.Add(StringGrid1.Cells[x,y]); end; // Vertrpl.Add(IntToStr(StringGrid1.ColWidths[x])); // diese Zeile löschen // Vertrpl.Add(IntToStr(StringGrid1.RowHeights[x])); // diese Zeile löschen end; for x:= 0 to StringGrid1.ColCount-1 do // diese Zeilen einfügen Vertrpl.Add(IntToStr(StringGrid1.ColWidths[x])); // (von _x_ abhängig!) for y:= 0 to StringGrid1.RowCount-1 do // diese Zeilen einfügen Vertrpl.Add(IntToStr(StringGrid1.RowHeights[y])); // (von _y_ abhängig!) //Edit: auch die x-Schleife muß raus, sonst stimmt die Reihenfolge nicht! Gruß Hawkeye |
Re: Logisches problem
:pale: :gruebel: :wiejetzt:
Ich glaub jetzt bin ich total verwirt |
Re: Logisches problem
Sorry für die Verwirrung, ich versuche das mal zu erklären.
Das war dein Originalcode:
Delphi-Quellcode:
Du speicherst zunächst alle Zellen des Stringgrids ab, danach alle Spaltenbreiten und dann alle Zeilenhöhen.
for x:= 0 to StringGrid1.ColCount-1 do
for y:= 0 to StringGrid1.RowCount-1 do Vertrpl.Add(StringGrid1.Cells[x,y]); for x:= 0 to StringGrid1.ColCount-1 do Vertrpl.Add(IntToStr(StringGrid1.ColWidths[x])); for x:= 0 to StringGrid1.RowCount-1 do Vertrpl.Add(IntToStr(StringGrid1.RowHeights[x])); Bei Formatieren deines Codes wurde folgendes daraus (Beitrag #6):
Delphi-Quellcode:
Fehler 1: Es werden nun nicht mehr RowCount Zeilenhöhen gespeichert sondern ColCount.
for x:= 0 to StringGrid1.ColCount-1 do
begin for y:= 0 to StringGrid1.RowCount-1 do begin Vertrpl.Add(StringGrid1.Cells[x,y]); end; // for y:= 0 to StringGrid1.RowCount-1 Vertrpl.Add(IntToStr(StringGrid1.ColWidths[x])); Vertrpl.Add(IntToStr(StringGrid1.RowHeights[x])); end; // for x:= 0 to StringGrid1.ColCount-1 Fehler 2: Durch das Verlagern in die x-Schleife werden die Spaltenbreiten und Zeilenhöhen in die Zellendaten eingestreut. Nachdem jeder Spalte des Stringgrids folgt eine Spaltenbreite und darauf eine Zeilenhöhe. In meinem Beitrag #13 habe ich versucht, das zu korrigieren. Aber wie das mit der 13 so ist, ich habe einen Fehler übersehen und später meinen eigenen Beitrag überarbeitet. Fabian hat in Beitrag #10 deinen Code ebenfalls formatiert aber dabei die Schleifenstruktur nicht geändert. Deshalb hat sich dort der Fehler nicht eingeschlichen. Sind nun alle Klarheiten beseitigt? Gruß Hawkeye |
Re: Logisches problem
Naja das war ja vorher nicht das Problem das Speichern hat gut Funktioniert.
Das Problem war die Abfrage am Anfang, was immernoch nicht funkioniert. Ich ja ich habe mich selber total verwirt :stupid: :lol: |
Re: Logisches problem
Delphi-Quellcode:
Vielleicht so?if not ComboBox4.Items.IndexOf(ComboBox4.Text)> -1 Then begin Combobox4.Items.Add(ComboBox4.Text); end; end
Delphi-Quellcode:
oder so:
if ComboBox4.Items.IndexOf(ComboBox4.Text) <= -1 Then
begin Combobox4.Items.Add(ComboBox4.Text); end;
Delphi-Quellcode:
if not (ComboBox4.Items.IndexOf(ComboBox4.Text) > -1) Then
begin Combobox4.Items.Add(ComboBox4.Text); end; Grüße Klaus |
Re: Logisches problem
Hi...
Vielleicht ganz ersichtlich: Deiner:
Delphi-Quellcode:
Pseudocode:if not ComboBox4.Items.IndexOf(ComboBox4.Text)> -1 Then begin Combobox4.Items.Add(ComboBox4.Text); end;
Code:
Und das jetzt zu Delphi:
falls Position In Den Items Der ComboBox4 "nicht vorhanden" ist dann
Füge Item mit dem Text der ComboBox4 hinzu
Delphi-Quellcode:
if ComboBox4.Items.IndexOf(ComboBox4.Text) = -1 then // Wenn ".IndexOf" "-1" ergibt, dann ist der Eintrag nicht vorhanden begin Combobox4.Items.Add(ComboBox4.Text); // Füge ein Item hinzu (Hinweis: Wenn du es machst, während man den Text ändert, dann erstellt er ständig neue Einträge) end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:42 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