Disjunct cell selection on click

Hi,
we are using disjunct cell in AdvStringGrid,
it works well, user select cells holding CTRL key.
Is there a way to select disjunct cells clicking on cell?
Whe have tried by code, but on every left clic on a cell, selection is cleared,
selecting only last clicked cell.

Thanks
Claudio

Hi Claudio,

problably you wrong the mouse button.

Even in windows if you select more than one item if you click with left button the selection is cleared.

So, once you made your rows selection, press rigth button and show what you can do with current selection (common use is show a pop up with copy, move ecc..).

Have a nice day

Daniele

Hi,
I know that the "normal" behaviour of disjunct selection is that,
but our customer ask for allow disjunct selection using Left Mouse button,
so we were trying to understand if that was possibile.
You confirm that is not possibile, correct?

Thanks
Claudio

Hi Claudio,

as you know .... all is, quite, possible !!!

In this case is quite ... very quite ....

In order to make this possible i made a test for you ... and it's possible but with some limitations.

The first one is who i did a very quick sample,this means who you have to do some work to arrange this changes.

Here the workaraound for you (if you accept this one).

1) You have to create a AdvStriogGriid descendant

2) You have to customize the WMLButtonDown event

In code something like that:



TMyAdvStringGrid = Class(TAdvStringGrid)



Protected



    procedure WMLButtonDown(var Msg:TWMLButtonDown); message WM_LBUTTONDOWN;



Private



Public



End;



TForm2 = class(TForm)

    SG1: TAdvStringGrid; // Just a grid on the form ....

    procedure FormCreate(Sender: TObject);

    procedure FormDestroy(Sender: TObject);



private

    { Private declarations }

    MyG: TMyAdvStringGrid;





public

    { Public declarations }

end;



Procedure TMyAdvStringGrid.WMLButtonDown(var Msg: TWMMouse);

Var X,Y : Integer;

    Selected : Boolean;

begin

MouseToCell(Msg.XPos,Msg.YPos,X,Y);

Selected:=RowSelect[Y];

if Msg.Keys=MK_LBUTTON then

Begin

    if RowSelectCount>0 then

    Begin

      if Selected then

      Begin

          MessageDlg('Row selected ......' + IntToStr(RowSelectCount) + #13 +

          'Clicked on ' + IntToStr(Y) + ' Row',mtCustom, [mbCancel], 0);

      End

      Else

      Inherited;

    End

    else

    Inherited;

End;

Row:=Y;

Col:=X;

end;



procedure TForm2.FormCreate(Sender: TObject);

begin

MyG:=TMyAdvStringGrid.Create(Self);

MyG.Top:=SG1.Top;

MyG.Left:=SG1.Left + SG1.Width + 20;

MyG.Width:=SG1.Width;

MyG.Height:=SG1.Height;

MyG.Parent:=Self;

MyG.Options:=MyG.Options + [goRowSelect];

MyG.MouseActions.DisjunctRowSelect:=True;

end;



procedure TForm2.FormDestroy(Sender: TObject);

begin

FreeAndNil(MyG);

end;



run...



This work as your need (Select a row with crtl + left mouse button, click on a selected row with left mouse button BEFORE clear selection), but this is only a starting point.



Have a nice day

Daniele.