如何刷新表单中的所有表? LibreOffice Base

时间:2013-05-23 21:24:04

标签: libreoffice libreoffice-basic libreoffice-base

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

E.g。这根本不起作用:

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())

如何全部更新?

2 个答案:

答案 0 :(得分: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

答案 1 :(得分: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