首页 > 解决方案 > 查询 Powerbuilder 以获取某些复选框并输入 text/singelineedit 以获取 showig 消息框

问题描述

我有 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

标签: powerbuilder

解决方案


如果选中的任何复选框将阻止在输入文本后显示消息,则: 如果是 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 控件,您需要itemchangedDataWindow 控件的事件处理程序:

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

推荐阅读