Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Delphi 2007 - RzDBGrid.SelectedRows.CurrentRowSelected

Posted on 2007-11-26
7
Medium Priority
?
1,011 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 10

Accepted Solution

by:
dinilud earned 750 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 750 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month20 days, 18 hours left to enroll

810 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