Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Check unCheck Select UnSelect REPORTVIEW CHECKBOX Duplicate Values DialogControlGet DialogControlSet 1 4 24 26 DC_RVMATCHCOL DC_RVCHECKEDROWS
;============================================================ ; ; 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 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
;============================================================ ; ; 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. 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
Article ID: W17763
Filename: Select All REPORTVIEW Checkboxes with Duplicate Values.txt
File Created: 2013:08:15:14:59:08
Last Updated: 2013:08:15:14:59:08