Solved

Delphi 2007 - RzDBGrid.SelectedRows.CurrentRowSelected

Posted on 2007-11-26
7
982 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
System restore point 4 91
proper way to parse url in delphi 2 164
Create a path if not exists 7 69
Need Help Delphi 2010 CheckBox1 Stored value in memo 13 57
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

13 Experts available now in Live!

Get 1:1 Help Now