Jump to content


Photo

SelectFirst / SelectLast and Multiselect


  • Please log in to reply
12 replies to this topic

#1 DelphiToday

DelphiToday
  • Members
  • 146 posts
  • Gender:Male

Posted 20 May 2017 - 06:47 AM

Hello,

 

I use Multiselect without Scrollbars.

 

When I multiselect items and use SelectFirst / SelectLast with button control the entire selection is gone :(

How can I do this the right way?

 

Greetings.



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 21 May 2017 - 04:09 PM

Hi,

I have started with including Shift parameter into method, but until then you can call SelectCell method with Shift parameter. For example in Shift you can include ssCtrl or ssShift and it will select like you hold these keys.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 21 May 2017 - 04:15 PM

Hi,

I have implemented it now. You can replace existing methods with:


procedure TNxCustomGrid6.SelectFirst(Shift: TShiftState = []);
begin
  SelectCell(SelectedCol, FirstVisibleRow, Shift);
end;

procedure TNxCustomGrid6.SelectLast(Shift: TShiftState = []);
begin
  SelectCell(SelectedCol, LastVisibleRow, Shift);
end;

Can you please tell me if you find any problem with it. I will like to include it in official code.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#4 DelphiToday

DelphiToday
  • Members
  • 146 posts
  • Gender:Male

Posted 21 May 2017 - 06:14 PM

This is not working. Using TNextVirtualGrid6.

 

When using ssCtrl  for Shiftstate screen is not updated. Everything stays the same.

calling DataChange has no effect.

 

Regards.



#5 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 21 May 2017 - 08:19 PM

Hello,

This small example work fine:

procedure TForm5.Button1Click(Sender: TObject);
begin
  NextVirtualGrid61.SelectLast([ssCtrl]);
end;

procedure TForm5.Button2Click(Sender: TObject);
begin
  NextVirtualGrid61.SelectFirst([ssCtrl]);
end;

procedure TForm5.FormCreate(Sender: TObject);
begin
  NextVirtualGrid61.CellSource := NxVirtualCellSource61;
  NextVirtualGrid61.DataChanged;
end;

procedure TForm5.NxVirtualCellSource61GetCell(Sender: TObject; ACol, ARow: Integer; Cell: INxCell);
begin
  Cell.AsString := IntToStr(ARow);
end;

function TForm5.NxVirtualCellSource61GetRowCount(Sender: TObject): Integer;
begin
  Result := 10;
end;
Can you tell me do I miss to set something more in this demo?
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#6 DelphiToday

DelphiToday
  • Members
  • 146 posts
  • Gender:Male

Posted 21 May 2017 - 08:40 PM

I think I miss recent update. I will check and try again. 



#7 DelphiToday

DelphiToday
  • Members
  • 146 posts
  • Gender:Male

Posted 21 May 2017 - 09:37 PM

Now tested your code with latest update and if items are on ONE page seems to be good.

 

But if you have more pages it stays on the same page.

Please test it with 100 items.



#8 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 22 May 2017 - 06:25 PM

Hi,

Maybe calling NextVirtualGrid61.ScrollToSelected (after SelectLast) can help?

Also setting AutoScroll to True is good.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#9 DelphiToday

DelphiToday
  • Members
  • 146 posts
  • Gender:Male

Posted 22 May 2017 - 06:37 PM

Thanks that is much better. :)

 

Now last situation. I use SelectFirst and SelectLast to jump to begin and/or end of list. I don't want to select de last or first item? Any idea?



#10 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 22 May 2017 - 08:55 PM

Hi,

Maybe using ScrollToTop can help, or directly:

VertScrollBar.Last;

or

VertScrollBar.First;
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#11 DelphiToday

DelphiToday
  • Members
  • 146 posts
  • Gender:Male

Posted 22 May 2017 - 09:17 PM

Enough variation now.

 

When you use twice, selected is corrected.

NextGridBrowser.SelectFirst([ssCtrl]);
NextGridBrowser.SelectFirst([ssCtrl]);
NextGridBrowser.ScrollToSelected;

Is it a better idea to combine this ScrollToSelected in SelectFirst/SelectLast.See code:

procedure TNxCustomGrid6.SelectFirst(Shift: TShiftState = []);
begin
  SelectCell(SelectedCol, FirstVisibleRow, Shift);
  ScrollToSelected;
end;

procedure TNxCustomGrid6.SelectLast(Shift: TShiftState = []);
begin
  SelectCell(SelectedCol, LastVisibleRow, Shift);
  ScrollToSelected;
end;

What do you think?



#12 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 22 May 2017 - 09:52 PM

Hi,

Maybe some developers don't want to scroll automatically.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#13 DelphiToday

DelphiToday
  • Members
  • 146 posts
  • Gender:Male

Posted 22 May 2017 - 09:58 PM

Maybe you are right. Thank you.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users