Solved

Delphi 2007 - RzDBGrid.SelectedRows.CurrentRowSelected

Posted on 2007-11-26
7
988 Views
Last Modified: 2010-04-21
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.pFIBDataSetNotRAPermit contains the items not in the dataset):

procedure TFrmRA.RzBitBtn2Click(Sender: TObject);
begin
  RzDBGrid3.SelectedRows.Delete;
  DMod.pFIBDataSetNotRAPermit.CloseOpen(True);
end;

All works Fine.

However I'm using the following to add items to a grid:

procedure TFrmRA.RzBitBtn1Click(Sender: TObject);
begin
  DMod.pFIBDataSetNotRAPermit.First;
  while not DMod.pFIBDataSetNotRAPermit.eof do begin
    if RzDBGrid6.SelectedRows.CurrentRowSelected then begin
      DMod.pFIBDataSetRAPermit.Insert;
      DMod.pFIBDataSetRAPermitPERMIT_DESCRIPTION.Text := RzDBGrid6.SelectedField.AsString;
      DMod.pFIBDataSetRAPermit.Post;
    end;
    DMod.pFIBDataSetNotRAPermit.Next;
  end;
  DMod.pFIBDataSetNotRAPermit.CloseOpen(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
0
Comment
Question by:Donoss
  • 3
  • 2
  • 2
7 Comments
 
LVL 10

Expert Comment

by:dinilud
ID: 20355964
Give the dataset properties of Grids.
0
 
LVL 1

Expert Comment

by:carcotasu
ID: 20356328
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.
0
 

Author Comment

by:Donoss
ID: 20356375
Dinilud,

I'm not sure what you are saying here, can you please expand on your explanation?

0
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
LVL 10

Accepted Solution

by:
dinilud earned 250 total points
ID: 20356416
Means
   what is Dataset property of RzDBGrid6,RzDBGrid3 etc.
    Is any relation with pFIBDataSetRAPermitPERMIT and RzDBGrid6

0
 
LVL 1

Assisted Solution

by:carcotasu
carcotasu earned 250 total points
ID: 20356454
Before you click on the button you selected a row on the grid. Hell in the procedure TFrmRA.RzBitBtn1Click(Sender: TObject); you must select all row in the grid if you whant to parsing and get all record.

When to select a row automatical the grid put a bookmark and allways the selected field it's the same if you don't  select another row.

Sorry for my English...
0
 

Author Closing Comment

by:Donoss
ID: 31411166
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.pFIBDataSetNotRAPermit, it should have been DataSetRA not DataSetRAPermit, therefore when I'm doing the insert it was resetting DMod.pFIBDataSetNotRAPermit to the first record and copying this in.

Thanks again
0
 

Author Comment

by:Donoss
ID: 20356934
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.pFIBDataSetNotRAPermit, it should have been DataSetRA not DataSetRAPermit, therefore when I'm doing the insert it was resetting DMod.pFIBDataSetNotRAPermit to the first record and copying this in.

Thanks again
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question