您的位置:首页 > 数据库

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

2015-07-08 14:36 489 查看
$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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: