ListView1为何不显示复选框
本帖最后由 dnvplj 于 2015-3-29 13:25 编辑请问各位朋友,下面的代码为何不象下图中那样显示复选框,我以设置了,研究1天多了,也没整明白,望各位朋友指教,先谢谢了。
#Region
#AutoIt3Wrapper_UseX64=n
#EndRegion
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <File.au3>
#include <Array.au3>
#Region
Global $gu_Form1 = GUICreate("Form1", 615, 484, 192, 124)
Global $gu_Pic1 = GUICtrlCreatePic("", 0, 0, 609, 73)
Global $gu_ListView1 = GUICtrlCreateListView("", 5, 72, 603, 289, _
BitOR($GUI_SS_DEFAULT_LISTVIEW, _
$WS_HSCROLL, $WS_VSCROLL), _
BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, _
$LVS_EX_CHECKBOXES))
Global $gu_Button1 = GUICtrlCreateButton("Button1", 472, 448, 65, 25)
Global $gu_Button2 = GUICtrlCreateButton("Button2", 544, 448, 65, 25)
GUICtrlSetColor(-1, 0x000000)
Global $gu_Progress1 = GUICtrlCreateProgress(0, 400, 609, 13, $PBS_SMOOTH)
#EndRegion
_Main()
Exit
Func _Main()
While 1
_GUICtrlListView_AddColumn($gu_ListView1, "序号", 60)
_GUICtrlListView_AddColumn($gu_ListView1, "子文件夹", 410)
_GUICtrlListView_AddColumn($gu_ListView1, "大小", 70)
_GUICtrlListView_AddColumn($gu_ListView1, "版本", 70)
GUICtrlSetData($gu_Progress1, 0)
GUICtrlSetState($gu_Progress1, $GUI_HIDE)
GUISetState(@SW_SHOW)
Local $nMsg
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $gu_Button2
Exit
EndSwitch
WEnd
EndFunc ;==>_Main 本帖最后由 netegg 于 2015-3-29 13:35 编辑
没加项的时候好像是不显示
还有可能是你创建的listview不支持扩展属性,那个好像需要用个函数来指定 回复 2# netegg
谢谢“元老”的回复,怎么加项,能给一个小例子吗? 回复netegg
谢谢“元老”的回复,怎么加项,能给一个小例子吗?
dnvplj 发表于 2015-3-29 13:37 http://www.autoitx.com/images/common/back.gif
看看这个函数 _GUICtrlListView_CopyItems 的示例 GUICtrlCreateListViewitem 还是没有整明白,望高手给予解答为盼。 listview是用来放一项一项内容的,没放内容当然什么都看不到。Func _Main()
_GUICtrlListView_AddColumn($gu_ListView1, "序号", 60)
_GUICtrlListView_AddColumn($gu_ListView1, "子文件夹", 410)
_GUICtrlListView_AddColumn($gu_ListView1, "大小", 70)
_GUICtrlListView_AddColumn($gu_ListView1, "版本", 70)
; 添加项目.
_GUICtrlListView_AddItem($gu_ListView1, "行 1: 列 1", 0)
_GUICtrlListView_AddSubItem($gu_ListView1, 0, "行 1: 列 2", 1, 1)
_GUICtrlListView_AddSubItem($gu_ListView1, 0, "行 1: 列 3", 2, 2)
_GUICtrlListView_AddItem($gu_ListView1, "行 2: 列 1", 1)
_GUICtrlListView_AddSubItem($gu_ListView1, 1, "行 2: 列 2", 1, 2)
_GUICtrlListView_AddItem($gu_ListView1, "行 3: 列 1", 2)
GUICtrlSetData($gu_Progress1, 0)
GUICtrlSetState($gu_Progress1, $GUI_HIDE)
GUISetState(@SW_SHOW)
While 1
Local $nMsg
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $gu_Button2
Exit
EndSwitch
WEnd
EndFunc ;==>_Main 回复 7# shqf
首先感谢“shqf ”朋友的回复,有3个问题请给予指导,一是:序号应添加1、2、3...列,二:复选框应添加到复选框栏列,三是:如何添加图标到复选框后列。 回复 8# dnvplj
#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
Opt('MustDeclareVars', 1)
Global $Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work
_Main()
Func _Main()
Local $hImage, $hListView, $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $lvs_ex_checkboxes)
GUICreate("ListView Get Item Image", 400, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
_GUICtrlListView_SetExtendedListViewStyle($hListView, $exStyles)
GUISetState()
; Load images
$hImage = _GUIImageList_Create()
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16))
_GUICtrlListView_SetImageList($hListView, $hImage, 1)
; Add columns
_GUICtrlListView_AddColumn($hListView, "Column 1", 100)
_GUICtrlListView_AddColumn($hListView, "Column 2", 100)
_GUICtrlListView_AddColumn($hListView, "Column 3", 100)
; Add items
_GUICtrlListView_AddItem($hListView, "", 0)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1, 1)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2, 2)
_GUICtrlListView_AddItem($hListView, "", 1)
_GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1, 2)
_GUICtrlListView_AddItem($hListView, "", 2)
; Set item 1, subitem 1 image
_GUICtrlListView_SetItemImage($hListView, 1, 1, 1)
MsgBox(4160, "Information", "Item 1, SubItem 1 Image: " & _GUICtrlListView_GetItemImage($hListView, 1, 1))
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main 回复 8# dnvplj
不好意思,不太能理解你的三个问题,不过感觉问题一、二已不需其他listview(列表视图管理)知识就可以解决了,问题三从netegg的代码中也能找到解决的方法。 回复 10# shqf
就是下面图片的效果
回复 11# dnvplj
那和图片有什么关系,_GUICtrlListView_SetColumnOrderArray就行了 回复 12# netegg
您好元老,10楼的朋友说,不明白我的意思,所以我给他上一张图。
页:
[1]