资源描述:
《ListView控件功能综合应用代码》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
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,入口参数;ListView1是ListView控件对象.入口参数;HeadArrayO是个二维变体数组'入口参数;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控件是否显示网格线'返回或设置对象的边框样式'是否选择整行SelectCaseIsCheckBoxesCaseIs=TrueListView1.CheckBoxes=True'是否显示复选框EndSelectFori=LBound(HeadArray)ToUBound(HeadArray)SetclmX=ListView1.ColuinnHeaders.Add(,,HeadArray(i,0),HeadArray(i,1))NextSetitmX=N
6、othingSetclmX=NothingEraseHeadArray'清空内存空间ExitFunctionONERROR:IfErr.Number<>0ThenSelectCaseErr.NumberCaseElseMsgBox”错误代码:"&Err.Number&"错误描述:”&Err.Description,vbExclamation,"初始化”EndSelectEndIfEndFunction,入口参数;ListView1是控件名称,入口参数;ArrayValue是动态数组'功能;添加数据到ListView控件中PublicFunctionlnisFile(ByRefListVi
7、ew1AsListView,ByRefArrayValue()AsVariant)OnErrorGoToONERRORDimitmXAsListitem'定义一个Listitem对象DimiAsLongFori=LBound(ArrayVaiue)ToUBound(ArrayValue)SelectCaseiCase0SetitmX=ListView1.Listitems.Add(,,ArrayVaiue(i))'文件名称CaseE