Multi Select MSFlexGrid

aboka
aboka used Ask the Experts™
on
Hi! I have a VB6 MSFlexGrid control and the 'SelectionMode' is '1- By Row'. I would like to loop thru the grid and all thats selected(multi-selected) and 'print' them. But it will only 'print' the top most item. Below is my sample code -

For i = 1 To MSHFlexGrid.Rows -1
  MSHFlexGrid.Rows = i
  If MSHFlexGrid.RowSel = True Then Debug.Print MSHFlexGrid.Text
Next


Please advice and thank you,
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Head of Software Services
Commented:
Hi aboka,

You need to do it like this:

With MSHFlexgrid1
  For i = iif(.RowSel > .Row,.Row,.RowSel) To Iif(.RowSel > .Row,.RowSel,.Row)
    Debug.Print .TextMatrix(i,1) 'First column's value
  Next
End with

Tim Cottee MCSD, MCDBA, CPIM
Brainbench MVP for Visual Basic
http://www.brainbench.com

Experts-Exchange Advisory Board Member

Author

Commented:
To TimCottee -

Thank you very much ;)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial