Autor Beitrag
csigg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Mo 20.06.05 13:20 
Ich will in meinem DBGrid die selektierte zeile auslesen.
hab das folgerndermassen Versucht:
ausblenden Delphi-Quelltext
1:
2:
3:
datum := dbgAnwesenheit.SelectedRows.Items[0];
Von := dbgAnwesenheit.SelectedRows.Items[1];
Bis := dbgAnwesenheit.SelectedRows.Items[2];

Aber das funktioniert nicht. Wüsste aber nicht wie ich das anders machen soll.
Es geht da drum dass ich einen Datensatz von einem DB GRid ins andere kopieren will. Das ganze bezieht sich jeweils auf die gleiche Tabelle.
Mottor
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mo 20.06.05 13:38 
SelectedRows ist TbookmarkList

Delphi Help:
Zitat:
Im folgenden Beispiel werden die in einem Datenbankgitter ausgewählten Zeilen in ein Listenfeld kopiert.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.Button1Click(Sender: TObject);
var
  i, j: Integer;
  s: string;
begin
  if DBGrid1.SelectedRows.Count>0 then
    with DBGrid1.DataSource.DataSet do
      for i:=0 to DBGrid1.SelectedRows.Count-1 do
      begin
        GotoBookmark(pointer(DBGrid1.SelectedRows.Items[i]));
        for j := 0 to FieldCount-1 do
        begin

          if (j>0then s:=s+', ';
          s:=s+Fields[j].AsString;
        end;
        Listbox1.Items.Add(s);
        s:= '';
      end;
end;
csigg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Mo 20.06.05 14:58 
Ich hab ein Problem dabei, bei folgender Zeile:
ausblenden Delphi-Quelltext
1:
 j := dbgAnwesenheit.SelectedRows.Count;					

steht in J 0 drin auch wenn eine Zeile markiert wurde, kann mir jemand sagen wieso??
csigg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Mo 20.06.05 15:00 
habs grad rausgefunden, wenn ich Multiselect auf true stelle, dann steht jeweils die richtige zahl drin.