Devexpress사이트에서 Bastian Bauwens가 쓴 글이 있네요 참고하세요...
[Question]
As an example :
I have a 'normal' dbgrid, and a button , when button is pressed, i fill a
table with a code like this :
<!--CodeS-->
...
with Query,Query.DataSource.dataset do begin
for i := 0 to SelectedList.Count-1 do begin
GotoBookMark(SelectedList.items[i]);
with table do begin
append;
fieldByname('CodEmpresa').value := CodigoEmpresa;
post;
end;
end;
end;
<!--CodeE-->
My problem is : i just trying to made something like this with dxDBGrid, ok,
there's tons of propertys and methods, but, don't forget, i'm still newbie
with this tools. Help files included with Quantum DBGrid don't solve this
doubt, i found a tip who told me to use selectedNodes grid property to
access selected nodes and save TdxDbGridNode.ID values to a list. But how do
to this ? There's no a easy way ? I can't use bookmark ?
And finally, just to remenber , I wrote :
I'm brazilian guy and newbie with Express Quantum Grid, i started to use a
dxDBGrid, and in my app, end users makes few rows selections in a grid, all
works fine, but, i don't know what i need to get all of these selections and
send to a query, or worst : select some rows, change order or change
groupping, and (this is the trouble) and continue adding more rows to
selections without loose prior select.
Sorry my english and thanks any help in advance.
[Asnwer]
to access the selected records in a QuantumGrid there are a few
possibilities:
1. In LoadAllRecords mode (and in PartialLoad mode also I think) use
SelectedNodes property.
And BTW: This is a VERY easy and efficient way, as the data is already
stored in the node itself and you usually don't have to locate on the
dataset to get the things from the dataset you need.
2. If in standard grid mode, use the SelectedRows property. There is an
example in the help file, I copied it for you:
The following example copies the selected rows in a db grid to a list box.
<!--CodeS-->
procedure TForm1.Button1Click(Sender: TObject);
var
i, j: Integer;
s: string;
begin
if DBGrid1.SelectedRows.Count>0 then
with DBGrid1.DataSource.DataSet do
for i:=0 to DBGrid1.SelectedRows.Count-1 do
begin
GotoBookmark(pointer(DBGrid1.SelectedRows.Items[i]));
for j := 0 to FieldCount-1 do
begin
if (j>0) then s:=s+', ';
s:=s+Fields[j].AsString;
end;
Listbox1.Items.Add(s);
s:= '';
end;
end;
<!--CodeE-->
Anyway, if you don't have thousands of records, use the LoadAllRecords mode
and access the nodes via the SelectedNodes property.
Hope this helps. If you have any more questions, I'm ready to help you.
Wrote by Bastian Bauwens