Home > Back-end >  Dbgrid in multiple-choice state how to determine which lines are selected are there?
Dbgrid in multiple-choice state how to determine which lines are selected are there?

Time:09-21

Dbgrid in multiple-choice state how to determine which lines are selected are there?
GdSelected State can only judge in the currently selected line, can't judge which lines is selected,

CodePudding user response:

Delphi DBGrid lunch does not support multiple,

Multiple-choice, can use third party controls, or inherit a new DBGrid,

CodePudding user response:

 var I: integer; 
The begin
For I:=0 to DBGrid1. SelectedRows. Do the Count - 1
The begin
DBGrid1. The DataSource. The DataSet. GotoBookmark (Pointer (DBGrid1. SelectedRows. Items [I]));
ShowMessage (DBGrid1 DataSource. The DataSet. Fields. [0] AsString) are identical.
end;
end;

CodePudding user response:

I am not going to take the selected data, I am want to know which lines is selected, and then selected row discoloration

As such, the current line selected will not change color, only the selected guild discoloration

CodePudding user response:

The previous reply wrong, now reply as follows:


1, set the DBGrid can multi-select:
In the Settings Option dgRowSelect to True,

2, in the DBGrid interface, by shift + Ctrl + mouse clicks, the selected rows, the selected rows, shown as blue,

3, choose more lines of code operation: using cycle, through the judgment, to find,
 
With DBGrid1. DataSouece. The DataSet do
The begin
First;
While not Eof do
The begin
If DBGrid1. SelectedRows. CurrentRowSelected then//selected row
The begin
For I:=0 to DbGrid1. Columns. Do the Count - 1//get ranked
The begin
DBGrid1. Columns. The Items [I] Field. The Value//
ranks Value obtainedend;
end;
Next;
end;
end;

CodePudding user response:

Using SelectedRows and bookmarks can handle a bookmark

CodePudding user response:

Please carefully look at me on the third floor of the figure, only the selected color line, not the selected line (even if this line is the line) is not change color, like the line 3 on the graph,

CodePudding user response:

2 and 4 floor are selected rows value code, is not what I want, but still want to thank the two took time off to see my problem, thank you!

CodePudding user response:

Selected is automatically change color, do not need to write another process set up the base

CodePudding user response:

Comparing DBGridEh realize save trouble

CodePudding user response:

Use CXgrid checkbox
  • Related