listview到底怎么设置列的宽度? [已解决]
本帖最后由 茫然 于 2013-4-25 20:50 编辑我想通过列的宽度来使水平滚动条不显示出来,但是如果某列的数据长一些,这列的宽度就被自动加大了。如图:
现在这样
我想这样(这时我手工拖的)
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
$FROM = GUICreate("", 615, 408, -1, -1)
$list = GUICtrlCreateListView("编号|计算机|IP地址", 395, 4, 215, 398)
_GUICtrlListView_SetColumnWidth($list, 0, 40)
_GUICtrlListView_SetColumnWidth($list, 1, 65) ;这里无效
_GUICtrlListView_SetColumnWidth($list, 2, 70)
GUICtrlCreateListViewItem("001|1234567890123456789|192.168.100.100", $list)
#endregion ### END Koda GUI section ###
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
Sleep(100)
WEnd
你是要这样?
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
$FROM = GUICreate("", 615, 408)
$list = GUICtrlCreateListView("编号|计算机|IP地址", 395, 4, 215, 398)
GUICtrlCreateListViewItem("001|1234567890123456789|192.168.100.100", $list)
_GUICtrlListView_SetColumnWidth($list, 0, 40)
_GUICtrlListView_SetColumnWidth($list, 1, 65) ;这里无效
_GUICtrlListView_SetColumnWidth($list, 2, 70)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd 本帖最后由 茫然 于 2013-4-25 18:54 编辑
回复 2# 水木子
我晕菜了,这代码有效,但我没看出和我的哪里不一样!
看出来了,先设置宽度再放数据就无效。要先放数据再设置宽度... 回复水木子
我晕菜了,这代码有效,但我没看出和我的哪里不一样!
茫然 发表于 2013-4-25 18:43 http://www.autoitx.com/images/common/back.gif
眼神?先后顺序看不出? 这样也可以
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
$FROM = GUICreate("", 615, 408)
$list = GUICtrlCreateListView("编号|计算机|IP地址", 365, 4, 248, 398)
;_GUICtrlListView_SetExtendedListViewStyle($list, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
GUICtrlSendMsg(-1, 0x101E, 0, 38)
GUICtrlSendMsg(-1, 0x101E, 1, 92)
GUICtrlSendMsg(-1, 0x101E, 2, 105)
GUICtrlCreateListViewItem("001|123456789012|192.168.100.100", $list)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
本帖最后由 netegg 于 2013-4-25 19:51 编辑
好像都是初次显示的时候吧,获取滑动条句柄,直接隐藏
另外好像listview加list样式也可以 长知识了,办法还真不少啊 谢谢各位!
[已解决] 回复 1# 茫然
还可以这样
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
$FROM = GUICreate("", 615, 408, -1, -1)
$list = GUICtrlCreateListView("编号|计算机|IP地址", 395, 4, 215, 398)
_GUICtrlListView_SetColumnWidth($list, 0, 40)
_GUICtrlListView_SetColumnWidth($list, 1, 65) ;这里无效
_GUICtrlListView_SetColumnWidth($list, 2, 110)
;GUICtrlCreateListViewItem("001|1234567890123456789|192.168.100.100", $list)
_GUICtrlListView_AddItem($list,"001")
_GUICtrlListView_AddSubItem($list,0,"1234567890123456789",1)
_GUICtrlListView_AddSubItem($list,0,"192.168.100.100",2)
#endregion ### END Koda GUI section ###
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
Sleep(100)
WEnd _GUICtrlListView_SetColumnWidth 谢谢,正好用到!
页:
[1]