anchor.diff:  begin
     if ColCount = 0 then
       Exit;
  -  if Button = mbRight then
  -    if (SelectionType <> stNone) and Assigned(FOnPreparePopupMenu) and
  +  case Button of
  +    mbRight:
  +      if (SelectionType <> stNone) and Assigned(FOnPreparePopupMenu) and
  +         (FDrawGrid.MouseToGridZone(X, Y) = gzNormal) then
  +      begin
  +        FDrawGrid.MouseToCell(X, Y, LCol, LRow);
  +        // fixed rows
  +        Dec(LRow);
  +        LSelection := Selection;
  +        for i := 0 to High(LSelection.Selections) do
  +          if not LContains then
  +          begin
  +            with LSelection.Selections[i] do
  +              LContains := (LCol >= Left) and (LRow >= Top) and (LCol <= Right) and (LRow <= Bottom);
  +            Break;
  +          end;
  +        if not LContains then
  +          Exit;
  +        FOnPreparePopupMenu(Self, LSelection, LPopup);
  +        if Assigned(LPopup) then
  +          with FDrawGrid.ClientToScreen(TPoint.Create(X, Y)) do
  +            LPopup.PopUp(X, Y);
  +      end;
  +    mbLeft:
  +      if (SelectionType <> stNone) and (vgoAllowDeselect in FOptions) and
          (FDrawGrid.MouseToGridZone(X, Y) = gzNormal) then
  -    begin
  -      FDrawGrid.MouseToCell(X, Y, LCol, LRow);
  -      // fixed rows
  -      Dec(LRow);
  -      LSelection := Selection;
  -      for i := 0 to High(LSelection.Selections) do
  -        if not LContains then
  +      begin
  +        LSelection := GetSelection;
  +        if (FCurrentSelectionType <> stNone) and SelectionsEquals(LSelection, FLastSelection) then
           begin
  -          with LSelection.Selections[i] do
  -            LContains := (LCol >= Left) and (LRow >= Top) and (LCol <= Right) and (LRow <= Bottom);
  -          Break;
  +          ResetLastSelection;
  +          UpdateSelection(stNone)
  +        end
  +        else begin
  +          // lock for select event, otherwise we get false information about selection
  +          // (highly visible problem for deselection option)
  +          FIgnoreSelectionEvent := true;
  +          UpdateSelection(FSelectionType);
  +          FIgnoreSelectionEvent := false;
  +          FLastSelection := LSelection;
  +          GridSelection(nil, 0, 0);
           end;
  -      if not LContains then
  -        Exit;
  -      FOnPreparePopupMenu(Self, LSelection, LPopup);
  -      if Assigned(LPopup) then
  -        with FDrawGrid.ClientToScreen(TPoint.Create(X, Y)) do
  -          LPopup.PopUp(X, Y);
  -    end;
  +      end;
  +  end;
   end;
   
   procedure TCustomVisualGrid.SearchKindPopupMenuClick(Sender: TObject);
  
positive.code: end;
  
  procedure TCustomVisualGrid.SetSelectionType(AValue: TSelectionType);
  var
    LSelectionEvent: boolean;
  begin
    if FSelectionType=AValue then
      Exit;
  
    LSelectionEvent := FSelectionType=stNone;
    FSelectionType:=AValue;
    case FSelectionType of
      stNone: FDrawGrid.Options:=FDefaultDrawGridOptions;
      stCell: FDrawGrid.Options:=FDefaultDrawGridOptions+[goDrawFocusSelected];
      stRow: FDrawGrid.Options:=FDefaultDrawGridOptions+[goRowSelect];
      stMultiRow: FDrawGrid.Options:=FDefaultDrawGridOptions+[goRowSelect,goRangeSelect];
    end;
    if LSelectionEvent and Assigned(FOnSelection) then
      FOnSelection(Self, Selection);
  end;
  
  procedure TCustomVisualGrid.SetWidgetControl(AValue: TControl);
  
negative.code: 
  procedure TCustomVisualGrid.GridSelection(Sender: TObject; aCol, aRow: Integer);
  begin
    if (FCurrentSelectionType <> stNone) and Assigned(FOnSelection) and (not FIgnoreSelectionEvent) then
      FOnSelection(Self, Selection);
  end;
  
  