您可能需要使用數據窗口的查詢模式作爲特里提及。您必須向用戶提供說明,但基本用法是直接在DataWindow中輸入要匹配的值。有關詳細信息,請參閱主題在「DataWindow程序員指南」中爲用戶提供查詢功能。這是我在我的一個實用程序窗口中的代碼。它使用帶有工具欄按鈕的菜單將DataWindow置於查詢模式,並關閉查詢模式並進行檢索。我在菜單和DataWindow事件之間使用了PFC消息路由,但您可以簡單地通過按鈕單擊事件調用事件,在這種情況下,您會刪除修改菜單的行。
// this code is in an event in the DataWindow
// toggles query mode on and off
if "no" = object.dataWindow.queryMode then
// you may want to check for unsaved changes here and let the user go back
object.dataWindow.queryMode = "yes"
m_myMenu.m_rows.m_query.checked = TRUE // this has a button on the toolbar
else
m_myMenu.m_rows.m_query.checked = FALSE
acceptText()
object.dataWindow.queryMode = "no"
retrieve()
end if
爲了獲得最大的靈活性,在一些或所有列上設置criteria.override_edit ='yes'。下面的代碼在所有列上設置criteria.override_edit ='yes'。這可能不適合您的情況。沒有override_edit,用戶被限制爲輸入通過列驗證的查詢值。
// this code is in an event in the DataWindow
// it is called after the DataObject is set
// it sets criteria.override_edit='yes' for all the columns
string ls_describe, ls_modify, ls_col, ls_result
integer li_colCount, li_col
setTransObject(SQLCA)
ls_describe = "datawindow.column.count"
ls_result = dw_1.describe(ls_describe)
if not isnumber(ls_result) then
// logging code elided
ls_result = '0'
end if
li_colCount = integer(ls_result)
for li_col = li_colCount to 1 step -1
ls_col = "#" + string(li_col)
ls_modify = ls_col + ".criteria.override_edit='yes'"
ls_result = dw_1.modify(ls_modify)
if "" <> ls_result then
// every column may not have an edit, and some edits might not // have the property. it's just as fast to try to modify it as it
// is to check it
// logging code elided
end if
next
你嘗試過什麼?您可能只需要更多的數據窗口中的檢索參數,以進一步過濾結果。 – Bernard 2012-07-26 18:36:26
@somnath hehehe我聽到你的聲音 – Wepex 2012-07-31 15:37:49