Autor Beitrag
AirJordan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 53

WinXP, Win7, Win2008 Server
D7 Enterprise
BeitragVerfasst: So 08.05.05 10:34 
Hallo,

ich habe mit der TMS Komponente TDBAdvGrid folgende Probleme (hoffe es kann mir jemand helfen :) )

Die TDBAdvGrid Komponente habe ich mit einer Tabelle verbunden und es werden sieben Spalten angezeigt. Drei Spalten sind
ComboListen, die in Abhängigkeit von Bedingungen mit Werten gefüllt werden. Dafür benutze ich die Routine GetEditorType.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
procedure TfrmBVSHHaupt.dbBVSHKennziffernDetailGridGetEditorType(Sender: TObject; ACol, ARow: Integer; var AEditor: TEditorType);
var i, Spieltage, Mannschaften: Integer;
begin
  with dbBVSHKennziffernDetailGrid do
  case ACol of
  3:  begin
        aEditor := edComboList;
        ClearComboString;
        Spieltage := dbEditSpinSpieltage.Value;
        for i := 1 to Spieltage do ComboBox.Items.Add(IntToStr(i));
      end;
  4:  begin
        aEditor := edComboList;
        ClearComboString;
        Mannschaften := dbEditSpinTeamanzahl.Value;
        case Mannschaften of
        1,2,3: ComboBox.Items.Add('A');
        4,5:  begin
                ComboBox.Items.Add('A');ComboBox.Items.Add('B');
              end;
        6,7:  begin
                ComboBox.Items.Add('A');ComboBox.Items.Add('B');
                ComboBox.Items.Add('C');
              end;
        8,9:  begin
                ComboBox.Items.Add('A');ComboBox.Items.Add('B');
                ComboBox.Items.Add('C');ComboBox.Items.Add('D');
              end;
        10,11: begin
                ComboBox.Items.Add('A');ComboBox.Items.Add('B');
                ComboBox.Items.Add('C');ComboBox.Items.Add('D');
                ComboBox.Items.Add('E');
               end;
        12,13: begin
                ComboBox.Items.Add('A');ComboBox.Items.Add('B');
                ComboBox.Items.Add('C');ComboBox.Items.Add('D');
                ComboBox.Items.Add('E');ComboBox.Items.Add('F');
               end;
        14,15: begin
                ComboBox.Items.Add('A');ComboBox.Items.Add('B');
                ComboBox.Items.Add('C');ComboBox.Items.Add('D');
                ComboBox.Items.Add('E');ComboBox.Items.Add('F');
                ComboBox.Items.Add('G');
               end;
        16,17: begin
                ComboBox.Items.Add('A');ComboBox.Items.Add('B');
                ComboBox.Items.Add('C');ComboBox.Items.Add('D');
                ComboBox.Items.Add('E');ComboBox.Items.Add('F');
                ComboBox.Items.Add('G');ComboBox.Items.Add('H');
               end;
        end;
      end;
  5,6:begin
        aEditor := edComboList;
        ClearComboString;
        Mannschaften := dbEditSpinTeamanzahl.Value;
        for i := 1 to Mannschaften do ComboBox.Items.Add(IntToStr(i));
      end;
  end;
end;


Wenn jetzt aus der ComboListe ein Wert ausgewählt wird (zB ein Team), dann soll diese Auswahl natürlich in die Datenbank
eingetragen werden und es soll ein Feld "Bemerkung" neu berechnet werden! Dafür habe ich folgende Routine vorgesehen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TfrmBVSHHaupt.SetKennzifferBemerkung(AReihe, ASpalte: Integer);
var TeamA,TeamB,Spieltag,SpieltagBuchstabe: ShortString;
begin
  with dbBVSHKennziffernDetailGrid do
  begin
    TeamA := IntToStr(dmBVSH.dbBVSHKennzifferDetailTeam_1.Value);
    TeamB := IntToStr(dmBVSH.dbBVSHKennzifferDetailTeam_2.Value);
    Spieltag := IntToStr(dmBVSH.dbBVSHKennzifferDetailSpieltag.Value);
    SpieltagBuchstabe := dmBVSH.dbBVSHKennzifferDetailSpielpaarungsBuchstabe.Value;
    dmBVSH.dbBVSHKennzifferDetail.Edit;
    dmBVSH.dbBVSHKennzifferDetailBemerkung.Text := Spieltag+'.Spieltag, Spiel '+SpieltagBuchstabe+'=Team '+TeamA+' vs. Team '+TeamB;
    dmBVSH.dbBVSHKennzifferDetail.Post;
  end;
end;


Soweit so gut. Jetzt passiert, wenn man einen ComboList Eintrag auswählt, folgendes: Das Datenbankfeld wird zwar aktualisiert,
der Cursor wird aber einige Datensätze weiter positioniert. Ich habe manchmal das Gefühl, dass das genau da ist, wo man mit der
Maus hingeklickt hätte, wenn nicht die ComboListe davor wäre.

Das Feld Bemerkung wird ebenfalls irgendwo anders aktualisiert. Da habe ich noch kein System erkennen können. :evil:

Meine Fragen an euch:

1) In welchen Ereignissen muss ich Veränderungen bei der TMS TDBAdvGrid Komponente vornehmen?
Ich habe schon OnClick und OnClickCell ausprobiert. OnGetEditorType könnt ihr oben sehen...

2) Wie kann ich ACol und ARow benutzen, um auf den richtigen Datensatz zu positionieren?
Muss ich diese überhaupt benutzen?

3) Warum springt der Cursor wie wild in dem DBGrid hin und her?

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.

_________________
Wer nichts verdient außer Geld, verdient nichts außer Geld...
diabklick! Die Diabestes Tagebuchsoftware