TDBGrid: (dgMultiSelect in Options) and (not DataSet.Active) and LeftMouseDown = Exception
Original Reporter info from Mantis: SunyD @soner-a
-
Reporter name: Soner
Original Reporter info from Mantis: SunyD @soner-a
- Reporter name: Soner
Description:
If the TDBGrid has the option dgMultiselect and the Dataset of the DBGrid closed and the user clicks on mouse button then exception "Dataset Inactive" raises.
Caused by this function:
procedure TCustomDBGrid.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
//...
else begin
if Button=mbLeft then
ClearSelection(true); // <-- HERE !!!!!
if gz=gzFixedRows then
//...
if Button=mbLeft then
ClearSelection(true); // <-- HERE !!!!!
doMoveToColumn;
//...
end;
Solution:
procedure TCustomDBGrid.ClearSelection(selCurrent:boolean=false);
begin
if [dgMultiSelect,dgPersistentMultiSelect]*Options=[dgMultiSelect] then begin
//..
if SelCurrent and FDatalink.Active then // ADD HERE : and FDatalink.Active
SelectRecord(true);
//..
end;
Steps to reproduce:
-
Create new application
-
put TDbGrid on the form.
select dgMultiSelect from TDbGrid.Options -
put TDBf or other dataset you don't need any database
-
put TDataSource on the form
-
connect dbf, datasource with Dbgrid
-
Don't open database!
-
run the application and click somewhere in the dbgrid
Additional information:
I added solution in the description.
Mantis conversion info:
- Mantis ID: 31631
- OS: Windows
- OS Build: 7
- Build: SVN-REvision: 54278
- Platform: i386-win32
- Version: 1.6.4
- Fixed in version: 1.7 (SVN)
- Fixed in revision: 54520 (#e366739d)
- Target version: 1.8