Recent

Author Topic: Stringgrid: How to select multi rows (row1 +row5 +row23) and drag-drop select ?  (Read 22269 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Hello Lazarus lovers :P.

I have trouble with stringgrid.
Question 1 :
How can i select multiple rows in a StringList ?
With shift + left mouse i can select a range (row1 + row2 + row3 +...) but how to select particular rows (row1 + row7 + row10 +...) ?
Usualy i use Ctrl + left mouse but it does not work.

I use this parameters :

extendedselect := true ;
option.gorowselect := true;
option.gorangeselect := true;
dragmode := automatic ;

Question 2 :
With that multi selection, how to drag+drop the selection ? Witch button or shift + click i have to use for draggin ?
When i drag the selection into a accepted target object, after enddrag the selection of stringgrid source is changed
(from first row to initial selection).

I have tried with drag manual but... i loose.

Thanks for your help.    
« Last Edit: November 18, 2009, 03:02:18 pm by fredvs »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Blaazen

  • Hero Member
  • *****
  • Posts: 3239
  • POKE 54296,15
    • Eye-Candy Controls
I am afraid that TStringGrid cannot do it. Maybe some third party component based on TStringGrid. But unfortunally KGrid also still does not support it - I found some discussion from october (2009) and author said that possibly in next version will be this function implemented. So try contact him and ask for details.
I have no other solution for you  :(.
B.

Edit: link on KGrid http://www.tkweb.eu/en/delphicomp/kgrid.html
« Last Edit: November 18, 2009, 11:01:29 pm by Blaazen »
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

faber

  • Guest
StringGrid Selection is TGridRect so it's only a range.
If you want to more then one selected area you can use own procedures, like:
 - OnMouseDown if (liCol = 0) and (Key=Ctrl) ... then multi_rows[liRow]:=true
 - OnDrawCell if multi_rows[liRow] then canvas.Brush.Color:=SelectionColor;
 - "procedure DoCopyToClipboard; override;" and modify the procedure to include an array multi_rows


Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Thanks Blaazen, thanks faber.

That strange because, with filstbox and filelistbox, with multiselect := true, it works like charms.

PS Hi faber, i gonna try your idea, thanks.

Bye
« Last Edit: November 19, 2009, 07:41:12 pm by fredvs »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

wp

  • Hero Member
  • *****
  • Posts: 11917
Multi-selection of non-adjacent rows is possible by enabling multiselect mode (StringGrid.RangeSelectMode := rsmMulti), rowselect and rangeselect (StringGrid1.Options := StringGrid1.Options + [goRowSelect, goRangeSelect]).

See attached demo.

[EDIT]
To post to which I respond here is suddenly gone now...
« Last Edit: January 21, 2017, 12:21:16 pm by wp »

marcio2003

  • Jr. Member
  • **
  • Posts: 69
Hi,
Sorry because I erased my previous post, I think create new post will be better, but now we go here.
Thanks for fast reply, but it's no functionall. Is only a view efect.
We haven't access to rows selected list for work and unmark a selected row not work.
Sorry my bad english.
What can we do.
Congratulations Lazarus Team.

Win_7 - Laz_1.6.0
Lazarus 2.0.10 Windows 10 64bits

wp

  • Hero Member
  • *****
  • Posts: 11917
You mean a rowselect like in Excel where you click on a row header? No, this is not possible. TStringGrid does not have a well-defined row header like Excel sinc FixedCols can be zero.

Yes, row-select is only a visual effect: The selection is by cell, but the selection rectangle is extended to cover the entire row.

The multiselect operation should be revisited. For example, a selection cannot be undone by clicking a selected cell a second time. I'll have a look at it when I have time.

marcio2003

  • Jr. Member
  • **
  • Posts: 69
Thanks,
We go working too.
God bless.
Lazarus 2.0.10 Windows 10 64bits

 

TinyPortal © 2005-2018