Solved

Delphi 2007 - RzDBGrid.SelectedRows.CurrentRowSelected

Posted on 2007-11-26
7
975 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
APK file name 7 64
delphi exception 7 58
delphi parse string to params 3 83
Base1 Encode/Decode 3 39
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now