读取数据库的表并绑定到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
posted on 2015-07-08 14:36 jenney.qiu 阅读(901) 评论(0) 编辑 收藏 举报