AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi Delphi StringGrid und onMouseDown/onMouseUp Events => Fehler!

StringGrid und onMouseDown/onMouseUp Events => Fehler!

Ein Thema von Piiepmatz · begonnen am 23. Nov 2005 · letzter Beitrag vom 23. Nov 2005
Antwort Antwort
Piiepmatz

Registriert seit: 22. Nov 2005
3 Beiträge
 
#1

StringGrid und onMouseDown/onMouseUp Events => Fehler!

  Alt 23. Nov 2005, 16:29
Hallo Allerseits!

Ich hoffe, hier kann mir jemand helfen, steh nämlich gerade auf dem Schlauch.
Folgendes Problem:
Ich möchte eine Art Stundenplan programmieren, der ein StringGrid enthält und über ADO eine Access Tabelle einliest.
Nun kann der Benutzer über Click auf ein Feld ein Dialogfenster öffnen und die Daten eintragen. Der Name der Daten wird dann in das entsprechende Feld eingetragen.
Soweit so gut. Dann hab ich ein Pseudo Drag&Drop programmiert, aber mit einem onMouseDown, on MouseUp Ereignis.
Das funktioniert auch, aber jetzt trägt er den Namen, der über das Dialogfenster eingegeben wird immer in den
letzten Datensatz der Tabelle... Warum?

Bitte helft mir!
  Mit Zitat antworten Zitat
Benutzerbild von faux
faux

Registriert seit: 18. Apr 2004
Ort: Linz
2.044 Beiträge
 
Turbo Delphi für Win32
 
#2

Re: StringGrid und onMouseDown/onMouseUp Events => Fehler

  Alt 23. Nov 2005, 16:37
Hallo!

Es wäre mal cool, wenn du uns den entsprechenden Quelltext nicht verheimlichst...

Grüße
Faux
Faux Manuel
Wer weiß, dass er nichts weiß, weiß mehr, als der der nicht weiß, dass er nichts weiß.
GoTrillian
  Mit Zitat antworten Zitat
Piiepmatz

Registriert seit: 22. Nov 2005
3 Beiträge
 
#3

Re: StringGrid und onMouseDown/onMouseUp Events => Fehler

  Alt 23. Nov 2005, 16:42
Okay, dann leg ich mal los:

Delphi-Quellcode:
procedure TF_wp.FormCreate(Sender: TObject);
begin
   P_Spaltenbeschriften;
   P_Tabelleauslesen;
end;

procedure TF_wp.Sg_anzeigeSelectCell(Sender: TObject; ACol, ARow: Integer;
  var CanSelect: Boolean);
begin
       // Merkt sich die Koordinaten der ausgewählten Zelle
       Spaltenno := ACol;
       Zeilenno := ARow;
end;


// Diese Funktion gibt den Namen des Datensatzes zurück, der mit der aktuell
// ausgewählten Zelle verknüpft ist, damit dieser beim Lesen/Editieren direkt
// ansprechen kann...
function F_Datensatzermitteln : string;
begin
       if ((Spaltenno = 1) and (Zeilenno = 1)) then result := 'Pl_1';
       if ((Spaltenno = 1) and (Zeilenno = 2)) then result := 'Pl_2';
       if ((Spaltenno = 1) and (Zeilenno = 3)) then result := 'Pl_3';
       if ((Spaltenno = 1) and (Zeilenno = 4)) then result := 'Pl_4';
       if ((Spaltenno = 1) and (Zeilenno = 5)) then result := 'Pl_5';
       if ((Spaltenno = 1) and (Zeilenno = 6)) then result := 'Pl_6';
       if ((Spaltenno = 1) and (Zeilenno = 7)) then result := 'Pl_7';
       if ((Spaltenno = 1) and (Zeilenno = 8)) then result := 'Pl_8';
       if ((Spaltenno = 1) and (Zeilenno = 9)) then result := 'Pl_9';
       if ((Spaltenno = 1) and (Zeilenno = 10)) then result := 'Pl_10';
       if ((Spaltenno = 1) and (Zeilenno = 11)) then result := 'Pl_11';
       if ((Spaltenno = 1) and (Zeilenno = 12)) then result := 'Pl_12';
       if ((Spaltenno = 1) and (Zeilenno = 13)) then result := 'Pl_13';
       if ((Spaltenno = 1) and (Zeilenno = 14)) then result := 'Pl_14';
       if ((Spaltenno = 2) and (Zeilenno = 1)) then result := 'Pl_15';
       if ((Spaltenno = 2) and (Zeilenno = 2)) then result := 'Pl_16';
       if ((Spaltenno = 2) and (Zeilenno = 3)) then result := 'Pl_17';
       if ((Spaltenno = 2) and (Zeilenno = 4)) then result := 'Pl_18';
       if ((Spaltenno = 2) and (Zeilenno = 5)) then result := 'Pl_19';
       if ((Spaltenno = 2) and (Zeilenno = 6)) then result := 'Pl_20';
       if ((Spaltenno = 2) and (Zeilenno = 7)) then result := 'Pl_21';
       if ((Spaltenno = 2) and (Zeilenno = 8)) then result := 'Pl_22';
       if ((Spaltenno = 2) and (Zeilenno = 9)) then result := 'Pl_23';
       if ((Spaltenno = 2) and (Zeilenno = 10)) then result := 'Pl_24';
       if ((Spaltenno = 2) and (Zeilenno = 11)) then result := 'Pl_25';
       if ((Spaltenno = 2) and (Zeilenno = 12)) then result := 'Pl_26';
       if ((Spaltenno = 2) and (Zeilenno = 13)) then result := 'Pl_27';
       if ((Spaltenno = 2) and (Zeilenno = 14)) then result := 'Pl_28';
       if ((Spaltenno = 3) and (Zeilenno = 1)) then result := 'Pl_29';
       if ((Spaltenno = 3) and (Zeilenno = 2)) then result := 'Pl_30';
       if ((Spaltenno = 3) and (Zeilenno = 3)) then result := 'Pl_31';
       if ((Spaltenno = 3) and (Zeilenno = 4)) then result := 'Pl_32';
       if ((Spaltenno = 3) and (Zeilenno = 5)) then result := 'Pl_33';
       if ((Spaltenno = 3) and (Zeilenno = 6)) then result := 'Pl_34';
       if ((Spaltenno = 3) and (Zeilenno = 7)) then result := 'Pl_35';
       if ((Spaltenno = 3) and (Zeilenno = 8)) then result := 'Pl_36';
       if ((Spaltenno = 3) and (Zeilenno = 9)) then result := 'Pl_37';
       if ((Spaltenno = 3) and (Zeilenno = 10)) then result := 'Pl_38';
       if ((Spaltenno = 3) and (Zeilenno = 11)) then result := 'Pl_39';
       if ((Spaltenno = 3) and (Zeilenno = 12)) then result := 'Pl_40';
       if ((Spaltenno = 3) and (Zeilenno = 13)) then result := 'Pl_41';
       if ((Spaltenno = 3) and (Zeilenno = 14)) then result := 'Pl_42';
       if ((Spaltenno = 4) and (Zeilenno = 1)) then result := 'Pl_43';
       if ((Spaltenno = 4) and (Zeilenno = 2)) then result := 'Pl_44';
       if ((Spaltenno = 4) and (Zeilenno = 3)) then result := 'Pl_45';
       if ((Spaltenno = 4) and (Zeilenno = 4)) then result := 'Pl_46';
       if ((Spaltenno = 4) and (Zeilenno = 5)) then result := 'Pl_47';
       if ((Spaltenno = 4) and (Zeilenno = 6)) then result := 'Pl_48';
       if ((Spaltenno = 4) and (Zeilenno = 7)) then result := 'Pl_49';
       if ((Spaltenno = 4) and (Zeilenno = 8)) then result := 'Pl_50';
       if ((Spaltenno = 4) and (Zeilenno = 9)) then result := 'Pl_51';
       if ((Spaltenno = 4) and (Zeilenno = 10)) then result := 'Pl_52';
       if ((Spaltenno = 4) and (Zeilenno = 11)) then result := 'Pl_53';
       if ((Spaltenno = 4) and (Zeilenno = 12)) then result := 'Pl_54';
       if ((Spaltenno = 4) and (Zeilenno = 13)) then result := 'Pl_55';
       if ((Spaltenno = 4) and (Zeilenno = 14)) then result := 'Pl_56';
       if ((Spaltenno = 5) and (Zeilenno = 1)) then result := 'Pl_57';
       if ((Spaltenno = 5) and (Zeilenno = 2)) then result := 'Pl_58';
       if ((Spaltenno = 5) and (Zeilenno = 3)) then result := 'Pl_59';
       if ((Spaltenno = 5) and (Zeilenno = 4)) then result := 'Pl_60';
       if ((Spaltenno = 5) and (Zeilenno = 5)) then result := 'Pl_61';
       if ((Spaltenno = 5) and (Zeilenno = 6)) then result := 'Pl_62';
       if ((Spaltenno = 5) and (Zeilenno = 7)) then result := 'Pl_63';
       if ((Spaltenno = 5) and (Zeilenno = 8)) then result := 'Pl_64';
       if ((Spaltenno = 5) and (Zeilenno = 9)) then result := 'Pl_65';
       if ((Spaltenno = 5) and (Zeilenno = 10)) then result := 'Pl_66';
       if ((Spaltenno = 5) and (Zeilenno = 11)) then result := 'Pl_67';
       if ((Spaltenno = 5) and (Zeilenno = 12)) then result := 'Pl_68';
       if ((Spaltenno = 5) and (Zeilenno = 13)) then result := 'Pl_69';
       if ((Spaltenno = 5) and (Zeilenno = 14)) then result := 'Pl_70';
       if ((Spaltenno = 6) and (Zeilenno = 1)) then result := 'Pl_71';
       if ((Spaltenno = 6) and (Zeilenno = 2)) then result := 'Pl_72';
       if ((Spaltenno = 6) and (Zeilenno = 3)) then result := 'Pl_73';
       if ((Spaltenno = 6) and (Zeilenno = 4)) then result := 'Pl_74';
       if ((Spaltenno = 6) and (Zeilenno = 5)) then result := 'Pl_75';
       if ((Spaltenno = 6) and (Zeilenno = 6)) then result := 'Pl_76';
       if ((Spaltenno = 6) and (Zeilenno = 7)) then result := 'Pl_77';
       if ((Spaltenno = 6) and (Zeilenno = 8)) then result := 'Pl_78';
       if ((Spaltenno = 6) and (Zeilenno = 9)) then result := 'Pl_79';
       if ((Spaltenno = 6) and (Zeilenno = 10)) then result := 'Pl_80';
       if ((Spaltenno = 6) and (Zeilenno = 11)) then result := 'Pl_81';
       if ((Spaltenno = 6) and (Zeilenno = 12)) then result := 'Pl_82';
       if ((Spaltenno = 6) and (Zeilenno = 13)) then result := 'Pl_83';
       if ((Spaltenno = 6) and (Zeilenno = 14)) then result := 'Pl_84';
       if ((Spaltenno = 7) and (Zeilenno = 1)) then result := 'Pl_85';
       if ((Spaltenno = 7) and (Zeilenno = 2)) then result := 'Pl_86';
       if ((Spaltenno = 7) and (Zeilenno = 3)) then result := 'Pl_87';
       if ((Spaltenno = 7) and (Zeilenno = 4)) then result := 'Pl_88';
       if ((Spaltenno = 7) and (Zeilenno = 5)) then result := 'Pl_89';
       if ((Spaltenno = 7) and (Zeilenno = 6)) then result := 'Pl_90';
       if ((Spaltenno = 7) and (Zeilenno = 7)) then result := 'Pl_91';
       if ((Spaltenno = 7) and (Zeilenno = 8)) then result := 'Pl_92';
       if ((Spaltenno = 7) and (Zeilenno = 9)) then result := 'Pl_93';
       if ((Spaltenno = 7) and (Zeilenno = 10)) then result := 'Pl_94';
       if ((Spaltenno = 7) and (Zeilenno = 11)) then result := 'Pl_95';
       if ((Spaltenno = 7) and (Zeilenno = 12)) then result := 'Pl_96';
       if ((Spaltenno = 7) and (Zeilenno = 13)) then result := 'Pl_97';
       if ((Spaltenno = 7) and (Zeilenno = 14)) then result := 'Pl_98';
end;



// Diese Prozedur stellt den Cursor der aktuell geöffneten Tabelle auf die Position, die dem
// übergebenen eindeutigen Namen entspricht...
procedure P_Datensatzauswaehlen(Satzname : string);
begin
       if not F_wp.ADO_wp.Bof then F_wp.ADO_wp.First;

       while Satzname <> F_wp.ADO_wp.fieldbyname('Termin').asstring do F_wp.ADO_wp.Next;
end;

procedure P_Terminbearbeiten;
begin

       if F_wp.ADO_wp.fieldbyname('Name').asstring <> 'then
         begin
              F_Kollision.Show;
         end;

       F_Terminpflege.show;

end;

procedure TF_wp.Sg_anzeigeDblClick(Sender: TObject);
var String_temp : String;
begin

String_temp := F_Datensatzermitteln;
P_Datensatzauswaehlen(String_temp);

        if F_wp.ADO_wp.FieldByName('Termin').AsString = 'then
        showmessage('Bitte legen Sie über den Menüeintrag einen neuen Wochenplaner an!')
        else
        begin
        P_Datensatzauswaehlen(F_Datensatzermitteln);
        P_Terminbearbeiten;
        end;
end;

procedure TF_wp.Sg_anzeigeMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var String_temp : String;
begin
String_temp := F_Datensatzermitteln;
P_Datensatzauswaehlen(String_temp);

F_wp.ADO_wp.Edit;
Name_temp := F_wp.ADO_wp.FieldbyName('Name').asString;
Beschreibung_temp := F_wp.ADO_wp.FieldbyName('Beschreibung').asString;
F_wp.ADO_wp.Post;
end;

procedure TF_wp.Sg_anzeigeMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var String_temp : String;
begin
String_temp := F_Datensatzermitteln;
P_Datensatzauswaehlen(String_temp);

F_wp.ADO_wp.Edit;
F_wp.ADO_wp.FieldbyName('Name').asString := Name_temp;
F_wp.ADO_wp.FieldbyName('Beschreibung').asString := Beschreibung_temp;
F_wp.ADO_wp.Post;
P_Tabelleauslesen;
end;
und dann noch die Terminpflege, also das besagte Dialogfenster:

Delphi-Quellcode:
procedure TF_Terminpflege.Btn_AbbruchClick(Sender: TObject);
begin
   F_Terminpflege.Close;
end;

procedure TF_Terminpflege.Btn_OKClick(Sender: TObject);
var
   x,y : integer;
begin
        F_wp.ADO_wp.Edit;
        F_wp.ADO_wp.fieldbyname('Name').AsString := Edt_Terminname.Text;
        if Edt_Terminname.Text = 'then
        Edt_Beschreibung.Text := ''
        else
        F_wp.ADO_wp.fieldbyname('Beschreibung').AsString := Edt_Beschreibung.Text;
        F_wp.ADO_wp.Post;

        P_Tabelleauslesen;


       //Der Inhalt der aktuellen Tabelle wird ausgelesen und ins String Grid übertragen.
      //Dabei wird nur das Feld "Name verwendet"...

   //Der erste Datensatz der Tabelle wird ausgewählt...
  { if F_wp.ADO_wp.Bof = false then F_wp.ADO_wp.First;


  //Diese Schleife durchläuft die Spalten gemäß der Anzahl derselben,
  //und füllt die Zellen mit dem Inhalt des Name-Feldes...
  For y := 1 to 7 do
    begin
      For x := 1 to 14 do
        begin
          F_wp.Sg_anzeige.cells[y,x] :=  F_wp.ADO_wp.FieldByName('Name').AsString;
          F_wp.ADO_wp.Next;
        end;
     end; }


    F_Terminpflege.Close;

    Edt_Terminname.Text := '';
    Edt_Beschreibung.Text := '';

end;
  Mit Zitat antworten Zitat
Benutzerbild von jim_raynor
jim_raynor

Registriert seit: 17. Okt 2004
Ort: Berlin
1.251 Beiträge
 
Delphi 5 Standard
 
#4

Re: StringGrid und onMouseDown/onMouseUp Events => Fehler

  Alt 23. Nov 2005, 16:56
Kleiner Tipp. Deine 98 If Abfragen kannst löschen und durch:

result := 'Pl_'+IntToStr(((Spaltenno-1)*14)+Zeilenno); ersetzen.

Ist bissle kürzer
Christian Reich
Schaut euch mein X-COM Remake X-Force: Fight For Destiny ( http://www.xforce-online.de ) an.
  Mit Zitat antworten Zitat
Piiepmatz

Registriert seit: 22. Nov 2005
3 Beiträge
 
#5

Re: StringGrid und onMouseDown/onMouseUp Events => Fehler

  Alt 23. Nov 2005, 17:04
Ja, danke, macht es "etwas" übersichtlicher. Nur leider funktioniert es trotzdem noch nicht...
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:57 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz