資源描述:
《ListView控件功能綜合應用代碼》由會員上傳分享,免費在線閱讀,更多相關內(nèi)容在工程資料-天天文庫。
1、ListView控件的報表功能應用代碼'功能;檢查ListView控件是否已初始化PublicFunctionListViewHead(ByRefListViewNameAsListView,ByRefListViewArrayOAsVariant,ByVaiListViewTagNameAsString,ByVaiIsCheckBoxesAsBoolean)OnErrorGoToONERRORStaticInitializeAsLongStaticListViewTagOAsVariantDimiAsLongDimHeadAsBooleanReDimPreserveListViewTa
2、g(Initialize)Fori=0ToUBound(ListViewTag)IfListViewTagName=ListViewTag(i)ThenHead=TrueExitForElseHead=FalseEndIfNextIfHead=FalseThenCallMdlListView.ListViewInitialize(ListViewName,ListViewArray,IsCheckBoxes)'初始化控件ListViewTag(Initialize)=ListViewTagNameInitialize=Initialize+1EndIfExitFunctionONERRO
3、R:IfEiT.Number<>0ThenSelectCaseErr.NumberCaseElseMsgBox”錯誤代碼:"&Err.Number&"錯誤描述:"&Err.Description,vbExclamation,"初始化"EraseListViewTagEndSelectEndIfEndFunction,入口參數(shù);ListView1是ListView控件對象.入口參數(shù);HeadArrayO是個二維變體數(shù)組'入口參數(shù);IsCheckBoxes是否要顯示復選框,功能;ListView控件初始化為報表格式PrivateFunctionListViewInitialize(ByRef
4、IsCheckBoxesAsBoolean)OnErrorGoToONERRORDimitmXAsListitem可通用初始化ListView控件ListView1AsListView,ByRefHeadArrayOAsVariant,ByVai'定義一個Listitem對象DimclmXAsColumnHeader加ColumnHeaderso列寬度等于控件的寬度DimiAsLongListView1.Listltems.ClearListView1.View=IvwReportListView1.Gridlines=TrueListView1.BorderStyle=ccFixedS
5、ingleListView1.FullRowSelect=True,刷新ListView控件'報表格式'確定在“報表”視圖中ListView控件是否顯示網(wǎng)格線'返回或設置對象的邊框樣式'是否選擇整行SelectCaseIsCheckBoxesCaseIs=TrueListView1.CheckBoxes=True'是否顯示復選框EndSelectFori=LBound(HeadArray)ToUBound(HeadArray)SetclmX=ListView1.ColuinnHeaders.Add(,,HeadArray(i,0),HeadArray(i,1))NextSetitmX=N
6、othingSetclmX=NothingEraseHeadArray'清空內(nèi)存空間ExitFunctionONERROR:IfErr.Number<>0ThenSelectCaseErr.NumberCaseElseMsgBox”錯誤代碼:"&Err.Number&"錯誤描述:”&Err.Description,vbExclamation,"初始化”EndSelectEndIfEndFunction,入口參數(shù);ListView1是控件名稱,入口參數(shù);ArrayValue是動態(tài)數(shù)組'功能;添加數(shù)據(jù)到ListView控件中PublicFunctionlnisFile(ByRefListVi
7、ew1AsListView,ByRefArrayValue()AsVariant)OnErrorGoToONERRORDimitmXAsListitem'定義一個Listitem對象DimiAsLongFori=LBound(ArrayVaiue)ToUBound(ArrayValue)SelectCaseiCase0SetitmX=ListView1.Listitems.Add(,,ArrayVaiue(i))'文件名稱CaseE