查询Powerbuilder的某些复选框,并为showig消息框输入文本/ singelineedit

时间:2019-01-24 05:18:08

标签: powerbuilder

我有3个复选框和1个输入文本。

如果我单击复选框,然后在输入文本中输入一些文本,那么我不希望出现该消息框。

如果我未单击复选框,但输入了文字,则消息框应显示。

我的问题是“如何在Powerbuilder中做到这一点?”

这是我的代码:

if Not IsNull(f_na) or Not IsNull(f_dep) or Not IsNull(f_krd) and IsNull (c_ao) then
    messagebox ('Perhatian','Kode AO baru harus diisi')
    return
end if

1 个答案:

答案 0 :(得分:0)

如果选中任何复选框将阻止在输入文本后显示消息,则: 如果是SingleLineEdit或MultiLineEdit控件,则在文本控件的modified事件处理程序中(即SingleLineEdit控件):

String ls_EditControlText

ls_EditControlText = this.Text

// If the text is not empty, and none of the checkboxes are checked, then 
// show a message and clear the input
IF NOT IsNull(ls_EditControlText) AND (ls_EditControlText <> "") THEN
    // f_na, f_dep, and f_krd are the Checkbox controls
    IF NOT (f_na.Checked OR f_dep.Checked OR f_krd.Checked) THEN
        MessageBox("Attention", "A new AO code must be filled in")

        this.Text = ""  // clear the input
    END IF
END IF

RETURN

对于DataWindow上的Edit或EditMask控件,您可以使用itemchanged事件处理程序作为DataWindow控件:

String ls_EditControlText

ls_EditControlText = data

// If the text is not empty, and none of the checkboxes are checked, then 
// show a message and clear the input
IF NOT IsNull(ls_EditControlText) AND (ls_EditControlText <> "") THEN
    // f_na, f_dep, and f_krd are the Checkbox controls
    IF NOT (f_na.Checked OR f_dep.Checked OR f_krd.Checked) THEN
        MessageBox("Attention", "A new AO code must be filled in")

        RETURN 2 // Reject the text input data but allow focus to change
    END IF
END IF

RETURN 0