* * *

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

Fred vS

  • Hero Member
  • *****
  • Posts: 1663
    • miXimum is the DJ's 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 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

Blaazen

  • Hero Member
  • *****
  • Posts: 2385
  • 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 1.9.0 r55743 FPC 3.0.2 x86_64-linux-qt Chakra, Qt 4.8.7, Plasma 5.9.4
Lazarus 1.6.4 r54278 FPC 3.0.2 i386-win32-win32/win64 Wine 2.4

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: 1663
    • miXimum is the DJ's 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 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

wp

  • Hero Member
  • *****
  • Posts: 3727
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 »
Lazarus trunk / fpc 3.0.0 / Win32

marcio2003

  • New member
  • *
  • Posts: 22
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

wp

  • Hero Member
  • *****
  • Posts: 3727
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.
Lazarus trunk / fpc 3.0.0 / Win32

marcio2003

  • New member
  • *
  • Posts: 22
Thanks,
We go working too.
God bless.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus