Reportview checkboxes with duplicate values

Started by badbacchus, August 10, 2013, 08:20:55 PM

Previous topic - Next topic

badbacchus

Hi, I have a report view checkbox question when there are duplicates in the first column.
The DialogControlSet docs for request 1 say
QuoteREPORTVIEW: (s) Checks or unchecks an item in a REPORTVIEW control. Use the function's set-info (fourth) parameter to indicate the first column text of the row to check or uncheck.  The text can be a delimited list to indicate which row should be checked or unchecked when multiple rows have the same first column text.

So, I should be able to provide a delimited list to indicate which row should be actioned (checked or unchecked) but what is the delimiter that needs to be used AND what is the text to be used. 
For example the following code (based on the tech DB) has the select all button only action the NON duplicate rows.

Code (winbatch) Select
#DefineSubRoutine MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,MyDialog_ChangeInfo)
   MSG_INIT=0                    ; The one-time initialization
   MSG_BUTTONPUSHED=2            ; Pushbutton or Picturebutton
   MSG_RVITEMSELROW=18           ; Reportview item select row
   MSG_RVCHECKEDITEM=20          ; Reportview checked/unchecked Item

   DC_CHECKBOX=1
   DC_TITLE = 4

   ;Return code constants
   RET_DO_CANCEL=0           ; Cancels dialog
   RET_DO_DEFAULT= -1        ; Continue with default processing for control
   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog
   ON_EQUAL = @TRUE                                         ; Initialize variable ON_EQUAL
   Switch MyDialog_Message                                  ; Switch based on Dialog Message type
      Case MSG_INIT                                         ; Standard Initialization message
         DialogProcOptions(MyDialog_Handle,MSG_BUTTONPUSHED,@TRUE)
         DialogProcOptions(MyDialog_Handle,MSG_RVITEMSELROW,@TRUE)
         DialogProcOptions(MyDialog_Handle,MSG_RVCHECKEDITEM,@TRUE)
         rowcount = ArrInfo(arrArray, 1)
         colcount = ArrInfo(arrArray, 2)
         rowindex = 0
         rowindexcb = 0
         arrItemsSelected = ArrDimension( rowcount, colcount )
         ArrInitialize(arrItemsSelected, '')
         arrItemsChecked = ArrDimension( rowcount, colcount )
         ArrInitialize(arrItemsChecked, '')
         Return(RET_DO_DEFAULT)

      Case MSG_RVITEMSELROW     ; !!!!!!!!! HANDLE ITEM SELECTIONS  !!!!!!!!!!!!!!!!!!
         ;Pause('MyDialog_ChangeInfo',MyDialog_ChangeInfo)
         ;Create an array to store the results
         indexSelected = Arraysearch( arrArray, MyDialog_ChangeInfo)
         arrItemsSelected[rowindex,0] = arrArray[indexSelected,0]
         arrItemsSelected[rowindex,1] = arrArray[indexSelected,1]
         ;Pause('SELECTED Item',arrArray[indexSelected,0]:',':arrArray[indexSelected,1])
         rowindex = rowindex+1
         Return(RET_DO_NOT_EXIT)

      Case MSG_RVCHECKEDITEM    ; !!!!!!!!! HANDLE CHECKBOX SELECTIONS  !!!!!!!!!!!!!!!!!!
         ;Pause('MyDialog_ChangeInfo',MyDialog_ChangeInfo)
         indexChecked = Arraysearch( arrArray, MyDialog_ChangeInfo)
         arrItemsChecked[rowindexcb,0] = arrArray[indexChecked,0]
         arrItemsChecked[rowindexcb,1] = arrArray[indexChecked,1]
         ;Pause('CHECKED Item',arrArray[indexChecked,0]:',':arrArray[indexChecked,1])
         rowindexcb = rowindexcb+1
         Return(RET_DO_NOT_EXIT)

      Case MSG_BUTTONPUSHED
        If MyDialog_Name == "PushButton_SelectAll"
              For x = 0 To ArrInfo(arrArray, 1)-1
                 item = arrArray[x,0]
DialogControlSet( MyDialog_Handle, "ReportView_1", DC_CHECKBOX, item)
        Next

              state = DialogControlGet( MyDialog_Handle, "PushButton_SelectAll", DC_TITLE  )
              If state == 'UnSelect All'
                    DialogControlSet( MyDialog_Handle, "PushButton_SelectAll", DC_TITLE, 'Select All' )
              Else
                    DialogControlSet( MyDialog_Handle, "PushButton_SelectAll", DC_TITLE, 'UnSelect All' )
              EndIf
             Return(RET_DO_NOT_EXIT)
        ElseIf MyDialog_Name == "PushButton_Cancel"        ; Cancel
              Return(RET_DO_CANCEL)
        ElseIf MyDialog_Name == "PushButton_OK"        ; OK
              Return(RET_DO_DEFAULT)
        EndIf                                              ; MyDialog_Name
        Return(RET_DO_DEFAULT)

   EndSwitch                                                ; MyDialog_Message
   Return(RET_DO_DEFAULT)
#EndSubRoutine                                                ; End of Dialog Callback MyDialogCallbackProc


filename = 'contacts_test.csv' ;'C:\TEMP\Data\CSV\Authors.csv'
arrArray = ArrayFileGetCSV(dirscript():filename, 1)


MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`ReportView Select all`
MyDialogX=138
MyDialogY=141
MyDialogWidth=566
MyDialogHeight=243
MyDialogNumControls=004
MyDialogProcedure=`MyDialogCallbackProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`165,223,036,012,PUSHBUTTON,"PushButton_SelectAll",DEFAULT,"Select All",2,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`265,223,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`365,223,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`010,010,450,200,REPORTVIEW,"ReportView_1",arrArray,DEFAULT,DEFAULT,30,221249536,DEFAULT,DEFAULT,"192|192|192"`

ButtonPushed=Dialog("MyDialog")


; Get Checked Items
checked = ""
For row = 0 To ArrInfo(arrItemsChecked, 1)-1
    data = ""
    For col = 0 To ArrInfo(arrItemsChecked, 2)-1
       item = arrItemsChecked[row,col]
       If data == '' Then data = item
       Else data = data:'|':item
    Next
    If checked == '' Then checked = data
    Else checked = checked:@TAB:data
Next
checked = StrTrim(checked)
AskItemlist('Checked items', checked, @TAB, @UNSORTED, @SINGLE )


; Get Selected Items
; The array variable defined in the Reportview
; will contain the selected rows once the dialog returns
selected = ""
For row = 0 To ArrInfo(arrArray, 1)-1
    data = ""
    For col = 0 To  ArrInfo(arrArray, 2)-1
       item = arrArray[row,col]
       If data == '' Then data = item
       Else data = data:'|':item
    Next
    If selected == '' Then selected = data
    Else selected = selected:@TAB:data
Next
checked = StrTrim(checked)
AskItemlist('Selected items', selected, @TAB, @UNSORTED, @SINGLE )


; or Get Selected items from callback
selectedcb = ""
For row = 0 To ArrInfo(arrItemsSelected, 1)-1
    data = ""
    For col = 0 To  ArrInfo(arrItemsSelected, 2)-1
       item = arrItemsSelected[row,col]
       If data == '' Then data = item
       Else data = data:'|':item
    Next
    If selectedcb == '' Then selectedcb = data
    Else selectedcb = selectedcb:@TAB:data
Next
selectedcb = StrTrim(selectedcb)
AskItemlist('Selected items - from callback', selectedcb, @TAB, @UNSORTED, @SINGLE )


Any help/clarification would be gratefully accepted.

bb

td

The list should contain the value you wish to check repeated the number of times equal to the occurrence of the value you wish to check.

The delimiter is the WinBatch default for delimited list - namely, the @Tab.   
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

badbacchus

Thanks Tony
If I understand correctly then the following should check all the boxes beside the two instances of 'bruce', but when run it only does one instance (the last).
Code (winbatch) Select
DialogControlSet( MyDialog_Handle, "ReportView_1", DC_CHECKBOX, strCat('bruce',@tab,'bruce'))

What's the secret sauce?

bb

td

Quote from: badbacchus on August 12, 2013, 03:15:13 PM
If I understand correctly then the following should check all the boxes beside the two instances of 'bruce', but when run it only does one instance (the last).

The function is doing exactly what it is designed to do. The reason for allowing delimited lists with request 1 is to make it possible to check exactly one item when there are duplicate items in a REPORTVIEW control. The help file topic reads "The text can be a delimited list to indicate which row should be checked or unchecked when multiple rows have the same first column text."  Note that 'row' is singular not plural.

Quote
What's the secret sauce?

Make a call to DialogControlSet  for each item you want checked.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

badbacchus

Ok, I give up on trying to understand that.  If you have a working sample of code can you post that please?

Cheers

Deana

Here is some sample code I put together to handle REPORTVIEW checkboxes with duplicate values:

Code (winbatch) Select
;============================================================
;
; How to Select All Checkboxes when data has duplicate values in the first row.
;
;============================================================

#DefineSubRoutine MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,MyDialog_ChangeInfo)
   MSG_INIT=0                    ; The one-time initialization
   MSG_BUTTONPUSHED=2            ; Pushbutton or Picturebutton
   MSG_RVITEMSELROW=18           ; Reportview item select row
   MSG_RVCHECKEDITEM=20          ; Reportview checked/unchecked Item
   DC_CHECKBOX=1
   DC_TITLE = 4
   DC_RVMATCHCOL=24
   DC_RVCHECKEDROWS=26       
   ;Return code constants
   RET_DO_CANCEL=0           ; Cancels dialog
   RET_DO_DEFAULT= -1        ; Continue with default processing for control
   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog
   ON_EQUAL = @TRUE                                         ; Initialize variable ON_EQUAL
   Switch MyDialog_Message                                  ; Switch based on Dialog Message type
      Case MSG_INIT                                         ; Standard Initialization message
         DialogProcOptions(MyDialog_Handle,MSG_BUTTONPUSHED,@TRUE)
         rowcount = ArrInfo(arrArray, 1)
         colcount = ArrInfo(arrArray, 2)
         rowindexdups = 0
         arrDupsFound = ArrDimension( rowcount ); Holds duplicate items that have already been handled in the reportview
         ArrInitialize(arrDupsFound, '')
         Return(RET_DO_DEFAULT)
      Case MSG_BUTTONPUSHED
        If MyDialog_Name == "PushButton_SelectAll"
              ArrInitialize(arrDupsFound, '') ; reset duplicates found array
              rowindexdups = 0
              ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              ; Grab the first item of each row
              ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              For row = 0 To Arrinfo(arrArray,1)-1  ;GetRow
                 item = arrArray[row,0]
                 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                 ; Search and select all duplicates
                 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                 ;DC_RVMATCHCOL (24) returns a two dimension array containing all REPORTVIEW rows
                 ;which have first column text matching one of the items specified as a
                 ;tab delimited list in the functions fourth parameter (request-value) . 
                 arrDups = DialogControlGet( MyDialog_Handle, "ReportView_1", DC_RVMATCHCOL, item  )
                 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                 ; If multiple items are found create tab delimited list of each item
                 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                 itemlist = ''
                  If ArrInfo(arrDups,1)-1 > 1  ; !!!!!!!!!! DUPLICATES FOUND !!!!!!!!!!!!!!!!!!
                    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    ; See if this item has already been found skip it
                    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    indexDupsFound = ArraySearch( arrDupsFound, item )
                    If indexDupsFound == -1
                       ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                       ;For each duplicate create a delimited list of each item and (un)check it
                       ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                       For y = 0 to ArrInfo(arrDups,1)-1
                             if itemlist == "" then itemlist = item
                             else itemlist = itemlist:@tab:item
                             ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                             ; Confirm state of button (Select All/UnSelect All)
                             ; and toggle checkbox if necessary
                             ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                             state = DialogControlGet( MyDialog_Handle, "PushButton_SelectAll", DC_TITLE  )
                             checked = DialogControlGet( MyDialog_Handle, "ReportView_1", DC_CHECKBOX, itemlist )
                             If state == 'UnSelect All'
                                ; if checked then uncheck it
                                If checked
                                   DialogControlSet( MyDialog_Handle, "ReportView_1", DC_CHECKBOX, itemlist )
                                Endif
                             Else; 'Select All'
                                If !checked
                                   DialogControlSet( MyDialog_Handle, "ReportView_1", DC_CHECKBOX, itemlist )
                                Endif
                             Endif
                       Next
                       ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                       ; Keep track of duplicates that have already been found
                       ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                       arrDupsFound[rowindexdups] = item
                       rowindexdups=rowindexdups+1
                    Endif
                 Else  ; !!!!!!!!!! NO DUPLICATES FOUND !!!!!!!!!!!!!!!!!!
                     ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     ; Confirm state of button (Select All/UnSelect All)
                     ; and toggle checkbox if necessary
                      ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     state = DialogControlGet( MyDialog_Handle, "PushButton_SelectAll", DC_TITLE  )
                     checked = DialogControlGet( MyDialog_Handle, "ReportView_1", DC_CHECKBOX, item )
                     If state == 'UnSelect All'
                        ; if checked then uncheck it
                        If checked
                          DialogControlSet( MyDialog_Handle, "ReportView_1", DC_CHECKBOX, item )
                        Endif
                     Else; 'Select All'
                        If !checked
                          DialogControlSet( MyDialog_Handle, "ReportView_1", DC_CHECKBOX, item )
                        Endif
                     Endif
                 Endif

              Next ;GetRow
              ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              ; Toggle button title
              ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              state = DialogControlGet( MyDialog_Handle, "PushButton_SelectAll", DC_TITLE  )
              If state == 'UnSelect All'
                    DialogControlSet( MyDialog_Handle, "PushButton_SelectAll", DC_TITLE, 'Select All' )
              Else
                    DialogControlSet( MyDialog_Handle, "PushButton_SelectAll", DC_TITLE, 'UnSelect All' )
              EndIf 
              Return(RET_DO_NOT_EXIT)
        ElseIf MyDialog_Name == "PushButton_Cancel"        ; Cancel
              Return(RET_DO_CANCEL)
        ElseIf MyDialog_Name == "PushButton_OK"        ; OK
              Return(RET_DO_DEFAULT)
        EndIf                                              ; MyDialog_Name
        Return(RET_DO_DEFAULT)
   EndSwitch                                                ; MyDialog_Message
   Return(RET_DO_DEFAULT)
#EndSubRoutine                                                ; End of Dialog Callback MyDialogCallbackProc

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

filename = 'C:\TEMP\Data\CSV\uselessinfo.csv'
arrArray = ArrayFileGetCSV(filename, 0)

MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`ReportView Select All with Duplicates`
MyDialogX=138
MyDialogY=141
MyDialogWidth=566
MyDialogHeight=243
MyDialogNumControls=004
MyDialogProcedure=`MyDialogCallbackProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`165,223,036,012,PUSHBUTTON,"PushButton_SelectAll",DEFAULT,"Select All",2,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`265,223,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`365,223,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`011,011,450,200,REPORTVIEW,"ReportView_1",arrArray,DEFAULT,DEFAULT,30,203423744,DEFAULT,DEFAULT,"192|192|192"`

ButtonPushed=Dialog("MyDialog")
Exit


Hope this helps.
Deana F.
Technical Support
Wilson WindowWare Inc.

td

Here is another approach.
Code (winbatch) Select

;============================================================
;
; How to Select All Checkboxes when data has duplicate values in the first row.
;
;============================================================

#DefineSubRoutine MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,MyDialog_ChangeInfo)
   MSG_INIT=0                    ; The one-time initialization
   MSG_BUTTONPUSHED=2            ; Pushbutton or Picturebutton
   MSG_RVITEMSELROW=18           ; Reportview item select row
   MSG_RVCHECKEDITEM=20          ; Reportview checked/unchecked Item
   DC_CHECKBOX=1
   DC_TITLE = 4
   DC_RVMATCHCOL=24
   DC_RVCHECKEDROWS=26
   ;Return code constants
   RET_DO_CANCEL=0           ; Cancels dialog
   RET_DO_DEFAULT= -1        ; Continue with default processing for control
   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog
   ON_EQUAL = @TRUE                                         ; Initialize variable ON_EQUAL
   Switch MyDialog_Message                                  ; Switch based on Dialog Message type
   Case MSG_INIT                                         ; Standard Initialization message
      DialogProcOptions(MyDialog_Handle,MSG_BUTTONPUSHED,@TRUE)
      rowcount    = ArrInfo(arrArray, 1)
      colcount    = ArrInfo(arrArray, 2)
      bCheckState = @False ; Starting state is unchecked.
      Return(RET_DO_DEFAULT)
   Case MSG_BUTTONPUSHED
      If MyDialog_Name == "PushButton_SelectAll"
         lItems      = ''                     ; List of first column items.
         nRowMax     = Arrinfo(arrArray,1)-1  ; Max index of items array.
         
         ; Toggle the state.
         bCheckState = !bCheckState           

         ; Check or unCheck each row as necessary.
         For nRow = 0 To nRowMax

            ; Add each item to list. 
            ; This works because only the last item in the list is checked or modified.
            lItems = ItemInsert( arrArray[nRow,0], -1, lItems, @Tab )
            if  bCheckState != DialogControlGet( MyDialog_Handle, "ReportView_1", DC_CHECKBOX, lItems  )
               DialogControlSet( MyDialog_Handle, "ReportView_1", DC_CHECKBOX, lItems )
            endif
         next

         ; Toggle the button state
         If bCheckState
            DialogControlSet( MyDialog_Handle, "PushButton_SelectAll", DC_TITLE, 'UnSelect All' )
         Else
            DialogControlSet( MyDialog_Handle, "PushButton_SelectAll", DC_TITLE, 'Select All' )
         EndIf
         Return(RET_DO_NOT_EXIT)
      ElseIf MyDialog_Name == "PushButton_Cancel"        ; Cancel
         Return(RET_DO_CANCEL)
      ElseIf MyDialog_Name == "PushButton_OK"        ; OK
         Return(RET_DO_DEFAULT)
      EndIf                                              ; MyDialog_Name
      Return(RET_DO_DEFAULT)
   EndSwitch                                                ; MyDialog_Message
   Return(RET_DO_DEFAULT)
#EndSubRoutine                                                ; End of Dialog Callback MyDialogCallbackProc

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

filename = 'C:\TEMP\Data\CSV\uselessinfo.csv'     ;   DirScript():
arrArray = ArrayFileGetCSV(filename, 0)

MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`ReportView Select All with Duplicates`
MyDialogX=138
MyDialogY=141
MyDialogWidth=566
MyDialogHeight=243
MyDialogNumControls=004
MyDialogProcedure=`MyDialogCallbackProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`165,223,036,012,PUSHBUTTON,"PushButton_SelectAll",DEFAULT,"Select All",2,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`265,223,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`365,223,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`011,011,450,200,REPORTVIEW,"ReportView_1",arrArray,DEFAULT,DEFAULT,30,203423744,DEFAULT,DEFAULT,"192|192|192"`

ButtonPushed=Dialog("MyDialog")
Exit
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

Deana

Wow Tony! Really interesting trick....

Code (winbatch) Select
; Add each item to list. 
; This works because only the last item in the list is checked.
lItems = ItemInsert( arrArray[nRow,0], -1, lItems, @Tab )
if  bCheckState != DialogControlGet( MyDialog_Handle, "ReportView_1", DC_CHECKBOX, lItems  )
               DialogControlSet( MyDialog_Handle, "ReportView_1", DC_CHECKBOX, lItems )
endif


Thanks for posting!
Deana F.
Technical Support
Wilson WindowWare Inc.

td

Well, I think it was intentionally designed to work that way but it just took awhile for the old light bulb to brighten. Speaking of shiny things, here is an extra credit example to polish the apple a bit.  It's a simple duplicate detector.
Code (winbatch) Select

;============================================================
;    amniziyaa amniziyaaeiln@gmail.com     176.122.117.26
; How to Select All Checkboxes when data has duplicate values in the first row.
;
;============================================================

#DefineSubRoutine MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,MyDialog_ChangeInfo)
   MSG_INIT=0                    ; The one-time initialization
   MSG_BUTTONPUSHED=2            ; Pushbutton or Picturebutton
   MSG_RVITEMSELROW=18           ; Reportview item select row
   MSG_RVCHECKEDITEM=20          ; Reportview checked/unchecked Item
   DC_CHECKBOX=1
   DC_TITLE = 4
   DC_RVMATCHCOL=24
   DC_RVCHECKEDROWS=26
   ;Return code constants
   RET_DO_CANCEL=0           ; Cancels dialog
   RET_DO_DEFAULT= -1        ; Continue with default processing for control
   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog
   ON_EQUAL = @TRUE                                         ; Initialize variable ON_EQUAL
   Switch MyDialog_Message                                  ; Switch based on Dialog Message type
   Case MSG_INIT                                         ; Standard Initialization message
      DialogProcOptions(MyDialog_Handle,MSG_BUTTONPUSHED,@TRUE)
      bCheckState = @False ; Starting state is unchecked.
      Return(RET_DO_DEFAULT)
   Case MSG_BUTTONPUSHED
      If MyDialog_Name == "PushButton_SelectDups"
         lFoundDups  = ''                     ; List of first column items with duplicats
         nRowMax     = Arrinfo(arrArray,1)-1  ; Max index of items array.
         
         ; Toggle the state.
         bCheckState = !bCheckState           

         ; Check or unCheck each row as necessary.
         For nRow = 0 To nRowMax
            strItem =  arrArray[nRow,0]

            ; Skip already processed items.
            if  ItemLocate( strItem, lFoundDups, @Tab) then continue

            ; Check for duplicate items
            nDupCount = ArrInfo(DialogControlGet( MyDialog_Handle, "ReportView_1", 24, strItem),1)
            if nDupCount > 1 ; Detected an item with duplicates.
                 
               ; Add to detected dups list
               lFoundDups = ItemInsert( strItem, -1, lFoundDups, @Tab )
                 
               ; Check all intances of this item.
               lDups = ''
               for nDup = 1 to nDupCount
                  lDups = ItemInsert( strItem, -1, lDups, @Tab )
                  if  bCheckState != DialogControlGet( MyDialog_Handle, "ReportView_1", DC_CHECKBOX, lDups)
                     DialogControlSet( MyDialog_Handle, "ReportView_1", DC_CHECKBOX,lDups )
                  endif
               next
            elseif bCheckState && DialogControlGet( MyDialog_Handle, "ReportView_1", DC_CHECKBOX, strItem)
               
               ; Keep non duplicated items unchecked
               DialogControlSet( MyDialog_Handle, "ReportView_1", DC_CHECKBOX,  strItem)
            endif
         next

         ; Toggle the button state.
         If bCheckState
            DialogControlSet( MyDialog_Handle, "PushButton_SelectDups", DC_TITLE, 'UnSelect Dups' )
         Else
            DialogControlSet( MyDialog_Handle, "PushButton_SelectDups", DC_TITLE, 'Select Dups' )
         EndIf
         Return(RET_DO_NOT_EXIT)
      ElseIf MyDialog_Name == "PushButton_Cancel"        ; Cancel
         Return(RET_DO_CANCEL)
      ElseIf MyDialog_Name == "PushButton_OK"        ; OK
         Return(RET_DO_DEFAULT)
      EndIf                                              ; MyDialog_Name
      Return(RET_DO_DEFAULT)
   EndSwitch                                                ; MyDialog_Message
   Return(RET_DO_DEFAULT)
#EndSubRoutine                                                ; End of Dialog Callback MyDialogCallbackProc

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

filename = 'C:\TEMP\Data\CSV\uselessinfo.csv'     ;   DirScript():    C:\TEMP\Data\CSV\
arrArray = ArrayFileGetCSV(filename, 0)

MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`ReportView Check Items with Duplicates`
MyDialogX=138
MyDialogY=141
MyDialogWidth=566
MyDialogHeight=243
MyDialogNumControls=004
MyDialogProcedure=`MyDialogCallbackProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`165,223,036,012,PUSHBUTTON,"PushButton_SelectDups",DEFAULT,"Select Dups",2,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`265,223,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`365,223,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`011,011,450,200,REPORTVIEW,"ReportView_1",arrArray,DEFAULT,DEFAULT,30,203423744,DEFAULT,DEFAULT,"192|192|192"`

ButtonPushed=Dialog("MyDialog")
Exit
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

badbacchus

And that is what I am talking about!  Awesome thanks Deana and Tony!  I got Deana's example with a minor change in the "If ArrInfo(arrDups,1)-1 >= 1  ; !!!!!!!!!! DUPLICATES FOUND !!!!!!!!!!!!!!!!!!" line and that method showed me the error of my ways/assumptions so I understand it now.
As for Tony's example, for me that was the extra credit example.  Very clever thanks!
bb