找回密码
 加入
搜索
查看: 9572|回复: 9

[AU3基础] listview到底怎么设置列的宽度? [已解决]

  [复制链接]
发表于 2013-4-25 17:56:42 | 显示全部楼层 |阅读模式
本帖最后由 茫然 于 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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2013-4-25 18:35:11 | 显示全部楼层
你是要这样?

#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:43:06 | 显示全部楼层
本帖最后由 茫然 于 2013-4-25 18:54 编辑

回复 2# 水木子


    我晕菜了,这代码有效,但我没看出和我的哪里不一样!
看出来了,先设置宽度再放数据就无效。要先放数据再设置宽度...
发表于 2013-4-25 18:54:43 | 显示全部楼层
回复  水木子


    我晕菜了,这代码有效,但我没看出和我的哪里不一样!
茫然 发表于 2013-4-25 18:43



    眼神?先后顺序看不出?
发表于 2013-4-25 19:14:39 | 显示全部楼层
这样也可以

#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
发表于 2013-4-25 19:49:53 | 显示全部楼层
本帖最后由 netegg 于 2013-4-25 19:51 编辑

好像都是初次显示的时候吧,获取滑动条句柄,直接隐藏
另外好像listview加list样式也可以
 楼主| 发表于 2013-4-25 20:49:13 | 显示全部楼层
长知识了,办法还真不少啊 谢谢各位!
[已解决]
发表于 2013-4-25 21:22:34 | 显示全部楼层
回复 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
发表于 2013-4-25 22:31:11 | 显示全部楼层
_GUICtrlListView_SetColumnWidth
发表于 2014-6-18 21:03:17 | 显示全部楼层
谢谢,正好用到!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-19 21:50 , Processed in 0.084267 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表