【问题标题】:How do I refresh all tables in a form? LibreOffice Base如何刷新表单中的所有表格? LibreOffice 基地
【发布时间】:2013-05-23 21:24:03
【问题描述】:

我在一个表单中有 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())

如何全部更新?

【问题讨论】:

    标签: libreoffice libreoffice-basic libreoffice-base


    【解决方案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
    

    【讨论】:

      【解决方案2】:

      重新加载表单不会刷新表格,表格控件通过在每一列上使用 .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
      

      【讨论】:

      • .refresh 方法似乎只适用于列表和组合框,不适用于其他类型的表格控件。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-23
      • 1970-01-01
      • 1970-01-01
      • 2012-12-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多