Donoss
asked on
Delphi 2007 - RzDBGrid.SelectedRows.CurrentRowSelected
Hi,
I'm using D2007, Vista Business and Raize 4.3.1.
I'm using the following code to delete dataset records from a a RzDBGrid (Note: DMod.pFIBDataSetNotRAPermi t contains the items not in the dataset):
procedure TFrmRA.RzBitBtn2Click(Send er: TObject);
begin
RzDBGrid3.SelectedRows.Del ete;
DMod.pFIBDataSetNotRAPermi t.CloseOpe n(True);
end;
All works Fine.
However I'm using the following to add items to a grid:
procedure TFrmRA.RzBitBtn1Click(Send er: TObject);
begin
DMod.pFIBDataSetNotRAPermi t.First;
while not DMod.pFIBDataSetNotRAPermi t.eof do begin
if RzDBGrid6.SelectedRows.Cur rentRowSel ected then begin
DMod.pFIBDataSetRAPermit.I nsert;
DMod.pFIBDataSetRAPermitPE RMIT_DESCR IPTION.Tex t := RzDBGrid6.SelectedField.As String;
DMod.pFIBDataSetRAPermit.P ost;
end;
DMod.pFIBDataSetNotRAPermi t.Next;
end;
DMod.pFIBDataSetNotRAPermi t.CloseOpe n(True);
end;
The first time I add a record it adds the selected item(s) and always adds the first item in the dataset, even when not selected. If I try to add additional records then only the selected items are added, the problem is only when adding the first item!!!!
Can anyone please help?
Many thanks
Andy
I'm using D2007, Vista Business and Raize 4.3.1.
I'm using the following code to delete dataset records from a a RzDBGrid (Note: DMod.pFIBDataSetNotRAPermi
procedure TFrmRA.RzBitBtn2Click(Send
begin
RzDBGrid3.SelectedRows.Del
DMod.pFIBDataSetNotRAPermi
end;
All works Fine.
However I'm using the following to add items to a grid:
procedure TFrmRA.RzBitBtn1Click(Send
begin
DMod.pFIBDataSetNotRAPermi
while not DMod.pFIBDataSetNotRAPermi
if RzDBGrid6.SelectedRows.Cur
DMod.pFIBDataSetRAPermit.I
DMod.pFIBDataSetRAPermitPE
DMod.pFIBDataSetRAPermit.P
end;
DMod.pFIBDataSetNotRAPermi
end;
DMod.pFIBDataSetNotRAPermi
end;
The first time I add a record it adds the selected item(s) and always adds the first item in the dataset, even when not selected. If I try to add additional records then only the selected items are added, the problem is only when adding the first item!!!!
Can anyone please help?
Many thanks
Andy
Give the dataset properties of Grids.
It is not suficient cu go next of the record, you must select then new row. look in the properties of the Grids maybe have property to select a row from code, something like this: RzDBGrid6.SelectedRows:= recno of table.
ASKER
Dinilud,
I'm not sure what you are saying here, can you please expand on your explanation?
I'm not sure what you are saying here, can you please expand on your explanation?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Guy's I've split the points for your help. My code above does in fact work fine, the problem was I had the wrong master datasource set for DMod.pFIBDataSetNotRAPermi t, it should have been DataSetRA not DataSetRAPermit, therefore when I'm doing the insert it was resetting DMod.pFIBDataSetNotRAPermi t to the first record and copying this in.
Thanks again
Thanks again
ASKER
Guy's I've split the points for your help. My code above does in fact work fine, the problem was I had the wrong master datasource set for DMod.pFIBDataSetNotRAPermi t, it should have been DataSetRA not DataSetRAPermit, therefore when I'm doing the insert it was resetting DMod.pFIBDataSetNotRAPermi t to the first record and copying this in.
Thanks again
Thanks again