Link to home
Start Free TrialLog in
Avatar of DennisPost
DennisPostFlag for Netherlands

asked on

VB6 multiple selections from msflexgrid to array with checks

Hi,

Our inhouse software covers invoice registration amongst other things. (Visual Basic 6)
Operational people enter their expected costs on a per file basis.
When the actual invoice arrives, the finance department registers the invoice in their part of the system, then matches the "expected costs" entered by the operational people to the actual invoice.

At the moment the finance users can only select one line at a time and the confirm.
I would like them to be able to match multiple lines in one go.
The selections are made from a msflexgrid.

To start with I created:
Private Type RowsToValidate
   DetID as long ' ID of the expected costs table
   RegNr as long ' The invoice registration number
   FlexRowNr as Byte ' Flex line nr ' Don't know if this is even necessary
End Type
Dim ValRows() as RowsToValidate 'Rows to confirm

When the user clicks on the flex to make the selection I would like:
A check to see if it has already been selected. If so remove it from the array (Deselect)
If it hasn't been selected I want to add it to the array.

Once the user has made all the selections they want, they will click on a button to do the confirmation (Validation)
This will be done by a function. For this to work i'll need to know how many values are in the array.
Can I use something like:
FOR i = 0 to max(Array) ????
or should I use the recordset count from the rs used to fill the flex in the first place???

As this is the first time I have worked with types, arrays and multiple selections on flexgrids, I am having a trouble getting my head around the logic needed and the steps involved.

Thanks in advance for any help you can offer.






Avatar of TreyH
TreyH
Flag of United States of America image

Will the selections be contiguous or non-contiguous?
The MSHFlexGrid by design does not offer multiple non-contiguous cell selection. You would probably have to investigate a 3rd party control to do that.
Avatar of DennisPost

ASKER

Hi TreyH,

That's some bad news as they will be non-contiguous.
I just finished another sub to allow the users to validate all available "excpected costs". :

dim i as integer
    'Fill the array with values from the recordset
    i = 1
    rsInvLines.MoveFirst
    Do While rsInvLines.EOF = False
        ValRows(i).DetID = rsInvLines!DetID
        ValRows(i).RegNr = Me.txtNum
        i = i + 1
        rsInvLines.MoveNext
    Loop
   
    'Cycle through the array calling the function ValidateRows each time
    For i = 1 To intRSRows
        ValidateRows ValRows(i).DetID, ValRows(i).RegNr
    Next i

This will suffice,
but I would still like to realize my question.

I will try some of these EE checkbox in flexgrid answers.
https://www.experts-exchange.com/questions/21737329/checkbox-in-flexgrid.html
https://www.experts-exchange.com/questions/20803581/Placing-Checkboxes-in-flexgrid.html
https://www.experts-exchange.com/questions/11819218/Adding-CheckBox-to-FlexGrid-Control.html
https://www.experts-exchange.com/questions/20313081/Adding-Checkbox-Control-to-Flexgrid.html

I you have a better idea, please don't be shy about letting know about it. :-)


ASKER CERTIFIED SOLUTION
Avatar of nirojexpert
nirojexpert
Flag of Nepal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Nirojexpert,

I am a little swamped with other higher priority work at the moment. I will try this out as soon as I can.

A few questions about your code though.
Where can I get these .gif files?
I assume SellID is just an integer value.
What kind of variable should the idArray be? Dim idArray() as String ??
I .col=1 contains the .text, this will not highlight the whole row then, right?
After I fill the idarray from Selid, how would I my array (ValidateRows ValRows(i).DetID, ValRows(i).RegNr)?

Thanks for your help!
A few questions about your code though.
Where can I get these .gif files? it can be any. instead of c:\ make a folder "images " where exe is built and then use the app.path & "\images\selected.gif"

I assume SellID is just an integer value. you put the ID of the record that will identify the record.
What kind of variable should the idArray be? Dim idArray() as String ??
I .col=1 contains the .text, this will not highlight the whole row then, right? . highlighting the whole row will depend on the property of grid.
After I fill the idarray from Selid, how would I my array (ValidateRows ValRows(i).DetID, ValRows(i).RegNr)? you will probably need to modify the function such that it can accept the whole array like ValidDateRows(Rows() ), etc
upload your code blocks, i will be able to help further