读取数据库的表并绑定到Listview

$aResultEventlog = _GetQueryTable($strSQL_Compare_FailRecordEventIDs, $iRowsEventlog, $iColsEventlog)
_BindDataToListview($aResultEventlog, $iRowsEventlog, $iColsEventlog, $lvEventlog)

Func _BindDataToListview($aResult, $iRows, $iCols, $hListview)
    _GUICtrlListView_DeleteAllItems($hListview)
    Dim $ilvDetailColumnCount = _GUICtrlListView_GetColumnCount ( $hListview )

    For $i = 0 To $ilvDetailColumnCount - 1
        _GUICtrlListView_DeleteColumn($hListview, 0)
    Next

    For $i = 0 To $iCols - 1
        _GUICtrlListView_InsertColumn($hListview, $i, $aResult[$i + 1])
    Next

    Local $iResultRowIndex = $iCols
    For $i = 0 To $iRows - 1
        $iResultRowIndex += 1
        _GUICtrlListView_AddItem($hListview, $aResult[$iResultRowIndex])
        For $j = 1 To $iCols - 1
            $iResultRowIndex += 1
            _GUICtrlListView_AddSubItem($hListview, $i, $aResult[$iResultRowIndex], $j)

            ;If $i = 0 Then
                If $aResult[$iResultRowIndex] = "" Then
                    _GUICtrlListView_SetColumnWidth($hListview, $j, 0)
                Else
                    _GUICtrlListView_SetColumnWidth($hListview, $j, $LVSCW_AUTOSIZE)
                EndIf
            ;EndIf
        Next
    Next

EndFunc

Func _GetQueryTable($sQueryString, ByRef $iRows, ByRef $iCols)

    Local $iRval, $aResult
    _SQLite_Open($SQLite_Data_Path)

     $iRval = _SQLite_GetTable(-1, $sQueryString, $aResult, $iRows, $iCols)
     _SQLite_Close()

    If $iRval = $SQLITE_OK Then
        Return $aResult
    EndIf

    Return ""
    ;_SQLite_Shutdown()
EndFunc

 

转载于:https://www.cnblogs.com/jenney-qiu/p/4630132.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值