1

我在一个表单中有 3 个表,它们使用 SQL 查询来选择数据。我需要以某种方式刷新它们,但没有任何效果。

例如,这根本不起作用:

oBaseContext = CreateUnoService("com.sun.star.sdb.DatabaseContext")
oDataSource = oBaseContext.getByName(dbName)
oCon = oDataSource.getConnection("", "")
oCon.getTables().refresh()

这仅更新第一个表:

oDisp = createUnoService("com.sun.star.frame.DispatchHelper")
oFrame = ThisComponent.getCurrentController().getFrame()
oDisp.executeDispatch(oFrame, ".uno:Refresh", "", 0, Array())

我如何更新它们?

4

2 回答 2

1

哦,我的上帝,这太容易了,我现在感觉很愚蠢:

Sub reloadAllTables
    Dim Forms : Forms = ThisComponent.DrawPage.Forms
    Dim i%
    For i = 0 To Forms.getCount()-1
        Forms.getByIndex(i).reload()
    Next
End Sub
于 2013-05-23T21:38:08.290 回答
0

重新加载表单不会刷新表格,表格控件通过在每一列上使用 .refresh 来刷新,例如 -

SUB refreshTables(oForm as object)
DIM cnt as integer, cnt2 as integer, tot as integer, tot2 as integer
DIM oFormObj as object

'get number of form object
tot = oForm.getCount - 1
IF tot > -1 THEN
    FOR cnt = 0 TO tot
        'next form object
        oFormObj = oForm.getByIndex(cnt) 
        'is object a table control AKA grid control
        IF oFormObj.ImplementationName = "com.sun.star.comp.forms.OGridControlModel" THEN
            'refresh each column
            tot2 = oFormObj.getCount - 1
            IF tot2 > -1 THEN
                FOR cnt2 = 0 TO tot2
                    oFormObj.getByIndex(cnt2).refresh
                NEXT
            ENDIF
        ENDIF
    NEXT
ENDIF
END SUB
于 2014-11-22T18:02:31.300 回答