Alpha Video Training
Results 1 to 5 of 5

Thread: Select all/Select none checkbox in dialog

  1. #1
    Member
    Real Name
    Mark Williams
    Join Date
    Dec 2005
    Posts
    322

    Default Select all/Select none checkbox in dialog

    I have a dialog box with multiple checkbox options. I am trying to add an option for 'select all' and another to 'select none'.

    This sort of works, but...

    Code:
    If vSelectAll = .t.
    	voption1 = .t.
    	voption2 = .t.
    	voption3 = .t.
    	voption4 = .t.
    	voption5 = .t.
    	voption6 = .t.
    	voption7 = .t.
    	voption8 = .t.
    	voption9 = .t.
    	vSelectNone = .f.
    End If
    If vSelectNone = .t.
    	voption1 = .f.
    	voption2 = .f.
    	voption3 = .f.
    	voption4 = .f.
    	voption5 = .f.
    	voption6 = .f.
    	voption7 = .f.
    	voption8 = .f.
    	voption9 = .f.
    	vSelectAll = .f.
    end if
    If i first click the 'Select all' checkbox, I cannot select the 'Select none' checkbox without first deselecting the 'Select All' checkbox.

    If i first select the 'Select none' checkbox, it allows me to then click the 'Select All' checkbox and unchecks the 'Select none' checkbox as desired.

    What am I missing?

    Thanks

  2. #2
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,311

    Default Re: Select all/Select none checkbox in dialog

    I'd need to see this in context, or more details, at least. For example, are the "select all" and "select none" controls in separate buttons, or are they two additional choices contained within the checkbox list? I'd favor separate buttons...

  3. #3
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Grand Rapids, Michigan
    Posts
    4,212

    Default Re: Select all/Select none checkbox in dialog

    Here is how I do it.

    Code:
    dim vall as L
    dim voption_list as C
    dim voption_select as C
    for i = 1 to 11
    	voption_list=voption_list+"option "+(""+i)+crlf()
    next
    
    ui_dlg_box("TEST",<<%dlg%
    {font=arial,10,b}{lf};
    Select all: (vall!evbx_*);;;
    [.23,16voption_select^$$voption_list];
    {lf};
    {sp=5}<Close>
    %dlg%,<<%code%
    if left(a_dlg_button,5)="evbx_"
    	if a_dlg_button="evbx_change"
    		if vall=.t.
    			voption_select=voption_list
    		else
    			voption_select=""
    		end if
    	end if
    a_dlg_button=""
    end if
    %code%)
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  4. #4
    Member
    Real Name
    Mark Williams
    Join Date
    Dec 2005
    Posts
    322

    Default Re: Select all/Select none checkbox in dialog

    Quote Originally Posted by Tom Cone Jr View Post
    I'd need to see this in context, or more details, at least. For example, are the "select all" and "select none" controls in separate buttons, or are they two additional choices contained within the checkbox list? I'd favor separate buttons...
    Here's the function I am trying to incorporate this in:

    Code:
    'Date Created: 20-Dec-2019 04:03:36 AM
    'Last Updated: 20-Dec-2019 04:03:36 AM
    'Created By  : Mark
    'Updated By  : Mark
    FUNCTION UploadtoRemote AS V ( )
    '
    DIM vokflag as L = .f.
    DIM vOption1 as L = .t.
    DIM vOption2 as L = .f.
    DIM vOption3 as L = .t.
    DIM vOption4 as L = .t.
    DIM vOption5 as L = .f.
    DIM vOption6 as L = .t.
    DIM vxstartdate as D = date()-365
    DIM vxenddate as D = date()
    DIM flist as C = ""
    DIM vOption7 as L = .t.
    DIM vOption8 as L = .f.
    DIM vOption9 as L = .f.
    DIM vSelectAll as L = .f.
    DIM vSelectNone as L = .f.
    'DIM xdialogStyle as P
    xdialogStyle.color = "#227+227+236"
    xdialogStyle.accentcolor = "White"
    '
    ' Setup header region
    DIM xDlgHeader as P
    xDlgHeader.HeadingText = "Upload Selected Data to Web"
    xDlgHeader.Image = "UploadIcon"
    xDlgHeader.BodyText = <<%str%
    - Information Line #1
    - Information Line #2
    - Information Line #3
    - Information Line #4
    %str%
    '
    dlgtitle = "Upload Files"
    
    varC_result = ui_dlg_box(dlgtitle,<<%dlg%
    {windowstyle=Gradient Horizontal Middle}
    {XdialogTitleSection=65,6xDlgHeader};;;;;
    {region}{font=arial,9,b}
    'adjust the second number below to adjust vertical size of left frame
    {frame=1,10:Data Files}{font=arial,9}
    {sp=2}(vOption1!OKFLAG) Option #1;;;
    {sp=2}(vOption2!OKFLAG) Option #2;
    {sp=2}(vOption3!OKFLAG) Option #3;
    {sp=2}(vOption4!OKFLAG) Option #4;
    {sp=5}(vOption5?vOption4) Option #5;
    'adjust space after first column
    {lf=2};;;;;;;;;
    {sp=4}(vSelectAll!OKFLAG) Select All
    {sp=3}(vSelectNone!OKFLAG) Select None;
    {endregion}{sp=4}
    {region}{font=arial,9,b}
    '{lf=2};
    'adjust frame vertical size for right frame y adjusting second number below
    {frame=1,11:Date Range}{font=arial,9}
    {lf=1};
    {'};
    {sp=2}From: [%DATE;P=popup.calendar(dtoc(vxstartdate));I=popup.calendar%.17vxstartdate!vxstartdate_*?vOption3 .or. vOption4] To: 
    [%DATE;P=popup.calendar(dtoc(vxenddate));I=popup.calendar%.17vxenddate!vxenddate_*?vOption3 .or. vOption4];
    'adjust the spacing after the date range fields
    {lf=1};
    {sp=2}(vOption6!OKFLAG) Option #6;
    {sp=2}(vOption9!OKFLAG) Option #9;
    {sp=2}(vOption8!OKFLAG) Option #8;
    {sp=2}(vOption7!OKFLAG) Option #7;;;;
    {endregion}
    'adjust vertical spacing after columns and before horizontal line
    {lf=1};
    {line=1,0};;;;;
    {font=arial,8}
    <20Upload Data Files!OK?VOKFLAG> <15Cancel!CANCEL>
    %dlg%,<<%code%
    
    If vSelectAll = .t.
    	vOption1 = .t.
    	vOption2 = .t.
    	vOption3 = .t.
    	vOption4 = .t.
    	vOption5 = .t.
    	vOption6 = .t.
    	vOption9 = .t.
    	vOption8 = .t.
    	vOption7 = .t.
    	vSelectNone = .f.
    End If
    If vSelectNone = .t.
    	vOption1 = .f.
    	vOption2 = .f.
    	vOption3 = .f.
    	vOption4 = .f.
    	vOption5 = .f.
    	vOption6 = .f.
    	vOption9 = .f.
    	vOption8 = .f.
    	vOption7 = .f.
    	vSelectAll = .f.
    end if
    
    IF a_dlg_button = "OKFLAG" THEN
    	SELECT
    		CASE vOption1 .and. vOption3 = .f. .and. vOption4 = .f.
    			vOption5 = .f.
    			vokflag = .t.
    		CASE vOption1 = .f. .and. vOption3 = .f. .and. vOption4 = .f. .and. vOption2
    			vOption5 = .f.
    			vokflag = .t.
    		CASE vOption1 .and. vOption3 .and. vOption4 = .f.
    			vOption5 = .f.
    			IF vxstartdate <> {} .and. vxenddate <> {} THEN
    				vokflag = .t.
    			ELSE
    				vokflag = .f.
    			END IF
    		CASE vOption1 .and. vOption3 = .f. .and. vOption4
    			'vOption5 = .t.
    			IF vxstartdate <> {} .and. vxenddate <> {} THEN
    				vokflag = .t.
    			ELSE
    				vokflag = .f.
    			END IF
    		CASE vOption1 .and. vOption3 .and. vOption4
    			'vOption5 = .t.
    			IF vxstartdate <> {} .and. vxenddate <> {} THEN
    				vokflag = .t.
    			ELSE
    				vokflag = .f.
    			END IF
    		CASE vOption1 = .f. .and. vOption3 .and. vOption4
    			'vOption5 = .t.
    			IF vxstartdate <> {} .and. vxenddate <> {} THEN
    				vokflag = .t.
    			ELSE
    				vokflag = .f.
    			END IF
    		CASE vOption1 = .f. .and. vOption3 = .f. .and. vOption4
    			'vOption5 = .t.
    			IF vxstartdate <> {} .and. vxenddate <> {} THEN
    				vokflag = .t.
    			ELSE
    				vokflag = .f.
    			END IF
    		CASE vOption1 = .f. .and. vOption3 .and. vOption4 = .f.
    			vOption5 = .f.
    			IF vxstartdate <> {} .and. vxenddate <> {} THEN
    				vokflag = .t.
    			ELSE
    				vokflag = .f.
    			END IF
    		CASE else
    			vOption5 = .f.
    			vokflag = .f.
    	END SELECT
    	a_dlg_button = ""
    END IF
    
    IF left(a_dlg_button,12) = "vxstartdate_" THEN
    	IF a_dlg_button = "vxstartdate_killfocus" THEN
    		vxstartdate = ctod(dtoc(vxstartdate))
    	END IF
    	a_dlg_button = ""
    	ui_dlg_event(dlgtitle,"OKFLAG")
    END IF
    
    IF left(a_dlg_button,10) = "vxenddate_" THEN
    	IF a_dlg_button = "vxenddate_killfocus" THEN
    		vxenddate = ctod(dtoc(vxenddate))
    	END IF
    	a_dlg_button = ""
    	ui_dlg_event(dlgtitle,"OKFLAG")
    END IF
    
    %code%)
    xbasic_wait_for_idle()
    
    IF varC_result <> "OK" THEN
    	end
    END IF
    
    IF vOption1 THEN
    ' Some code here
    END IF
    
    IF vOption2 THEN
    ' Some code here
    END IF
    
    IF vOption3 THEN
    ' Some code here
    ' Some code here
    END IF
    
    IF vOption4 THEN
    ' Some code here
    END IF
    '
    IF vOption4 .and. vOption5 THEN
    ' Some code here
    END IF
    '
    if vOption9 = .t. then
    ' Some code here
    else
    end if
    '
    if vOption8 = .t. then
    ' Some code here
    end if
    '
    if vOption6 = .t. then
    ' Some code here
    else
    end if
    
    if vOption7 = .t. then
    :a5.close()
    else
    end if
    
    END FUNCTION
    Thanks

  5. #5
    Member
    Real Name
    Andrew Davidowicz
    Join Date
    Aug 2018
    Location
    New Jersey
    Posts
    24

    Default Re: Select all/Select none checkbox in dialog

    Hey Mark,

    The event handlers on the All and None buttons are the same as the Options but you never use them for the same purpose. You need to make them unique like this and it will work:

    Code:
    varC_result = ui_dlg_box(dlgtitle,<<%dlg%
    {windowstyle=Gradient Horizontal Middle}
    {XdialogTitleSection=65,6xDlgHeader};;;;;
    {region}{font=arial,9,b}
    'adjust the second number below to adjust vertical size of left frame
    {frame=1,10:Data Files}{font=arial,9}
    {sp=2}(vOption1!OKFLAG) Option #1;;;
    {sp=2}(vOption2!OKFLAG) Option #2;
    {sp=2}(vOption3!OKFLAG) Option #3;
    {sp=2}(vOption4!OKFLAG) Option #4;
    {sp=5}(vOption5?vOption4) Option #5;
    'adjust space after first column
    {lf=2};;;;;;;;;
    {sp=4}(vSelectAll!ALL) Select All
    {sp=3}(vSelectNone!NONE) Select None;
    {endregion}{sp=4}
    {region}{font=arial,9,b}
    '{lf=2};
    'adjust frame vertical size for right frame y adjusting second number below
    {frame=1,11:Date Range}{font=arial,9}
    {lf=1};
    {'};
    {sp=2}From: [%DATE;P=popup.calendar(dtoc(vxstartdate));I=popup.calendar%.17vxstartdate!vxstartdate_*?vOption3 .or. vOption4] To: 
    [%DATE;P=popup.calendar(dtoc(vxenddate));I=popup.calendar%.17vxenddate!vxenddate_*?vOption3 .or. vOption4];
    'adjust the spacing after the date range fields
    {lf=1};
    {sp=2}(vOption6!OKFLAG) Option #6;
    {sp=2}(vOption9!OKFLAG) Option #9;
    {sp=2}(vOption8!OKFLAG) Option #8;
    {sp=2}(vOption7!OKFLAG) Option #7;;;;
    {endregion}
    'adjust vertical spacing after columns and before horizontal line
    {lf=1};
    {line=1,0};;;;;
    {font=arial,8}
    <20Upload Data Files!OK?VOKFLAG> <15Cancel!CANCEL>
    %dlg%,<<%code%
    
    if a_dlg_button = "ALL"
    	vOption1 = .t.
    	vOption2 = .t.
    	vOption3 = .t.
    	vOption4 = .t.
    	vOption5 = .t.
    	vOption6 = .t.
    	vOption9 = .t.
    	vOption8 = .t.
    	vOption7 = .t.
    	vSelectNone = .f.
    	a_dlg_button = ""
    End If
    If a_dlg_button = "NONE"
    	vOption1 = .f.
    	vOption2 = .f.
    	vOption3 = .f.
    	vOption4 = .f.
    	vOption5 = .f.
    	vOption6 = .f.
    	vOption9 = .f.
    	vOption8 = .f.
    	vOption7 = .f.
    	vSelectAll = .f.
    	a_dlg_button = ""
    end if
    %code%)
    Last edited by Al Buchholz; 12-20-2019 at 01:16 PM. Reason: added - %code%) - to coding

Similar Threads

  1. Remove checkbox on grid with Checkbox Select Colunn
    By asawyer13 in forum Mobile & Browser Applications
    Replies: 4
    Last Post: 03-02-2019, 07:11 PM
  2. Select ALL Checkbox
    By erichf in forum Application Server Version 10 - Web/Browser Applications
    Replies: 4
    Last Post: 10-11-2010, 06:25 PM
  3. Adding Select All to Checkbox Dialog Box
    By thebside in forum Alpha Five Version 7
    Replies: 2
    Last Post: 01-03-2007, 11:44 AM
  4. Select checkbox in WAS
    By Peter.Greulich in forum Archived Wishlist
    Replies: 2
    Last Post: 07-07-2006, 01:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •