DEV Community

Venkatesh Jonnagadla
Venkatesh Jonnagadla

Posted on

PowerBuilder - Dynamically Disable/access controls on a Window

Create a global function and pass the window to the function to achieve the same. Or you can create a window function also to achieve the same

int li_counter
DataWindow               ldw_DataWindow
CommandButton                     lcb_CommandButton
StaticText                     lst_StaticText
singleLineEdit              ls_singleLineEdit
checkbox                     lcb_checkbox
picturebutton              lpb_picturebutton
editmask                     lem_editmask
dropdownlistbox                      lddlb_dropdownlistbox
userObject luo_userobject
radioButton     lrb_radiobutton
groupBox         lgb_groupBox


for li_counter = 1 to upperbound(control[] )  
            choose case TypeOf(this.control[li_counter])
                        case DataWindow!
                                    ldw_DataWindow = this.control[li_counter]
                                    ldw_DataWindow.enabled = false                  
                        case CommandButton!                                   
                                    if this.control[li_counter].classname() <> 'cb_cancel' then
                                                lcb_CommandButton = this.control[li_counter]
                                                lcb_CommandButton.enabled = false
                                    end if
                        case StaticText!
                                    lst_StaticText = this.control[li_counter]
                                    lst_StaticText.enabled = false
                                    lst_StaticText.textColor= 134217745 //Disabled Text Color
                        case singleLineEdit!
                                    ls_singleLineEdit = this.control[li_counter]
                                    ls_singleLineEdit.enabled = false
                        case checkbox!
                                    lcb_checkbox = this.control[li_counter]
                                    lcb_checkbox.enabled = false
                        case picturebutton!
                                    lpb_picturebutton = this.control[li_counter]
                                    lpb_picturebutton.enabled = false
                        case editmask!
                                    lem_editmask = this.control[li_counter]
                                    lem_editmask.enabled = false
                        case dropdownlistbox!
                                    lddlb_dropdownlistbox = this.control[li_counter]      
                                    lddlb_dropdownlistbox.enabled = false
                        case userobject!
                                    luo_userobject = this.control[li_counter]       
                                    luo_userobject.enabled = false
                        case radiobutton!
                                    lrb_radiobutton = this.control[li_counter]      
                                    lrb_radiobutton.enabled = false
                        //case groupbox!
                                    //lgb_groupBox = this.control[li_counter]      
                                    //lgb_groupBox.enabled = false
                                    //lgb_groupBox.textcolor = 134217745
            end choose      
next

Enter fullscreen mode Exit fullscreen mode

Top comments (0)