找回密码
 加入
搜索
查看: 3093|回复: 3

[AU3基础] 关于ListView中字段的显示问题

[复制链接]
发表于 2010-7-15 00:32:06 | 显示全部楼层 |阅读模式
本帖最后由 lllangxx 于 2010-7-15 00:34 编辑

关于ListView中字段 一部分靠右一部分靠左显示  是什么原因呢?
如何让字段都左对齐?
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <GUIListBox.au3>
#include <DateTimeConstants.au3>
#include <GuiListView.au3>

Opt("GUIOnEventMode", 1)
Opt("TrayIconHide", 1)
Opt("GUICloseOnESC", 0)

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 454, 192, 114)

GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")

$Button1 = GUICtrlCreateButton("test", 472, 400, 121, 25, $WS_GROUP) ;write
GUICtrlSetOnEvent(-1, "Button1Click")

$Button2 = GUICtrlCreateButton("read", 20, 400, 121, 25, $WS_GROUP)  ;read
GUICtrlSetOnEvent(-1, "Button2Click")

$ListView1 = GUICtrlCreateListView("", 16, 8, 601, 385)             ;Listview
         _GUICtrlListView_SetExtendedListViewStyle($ListView1 ,BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) ;ListView样式
         _GUICtrlListView_AddColumn($ListView1, "test", 50, 0)
         _GUICtrlListView_AddColumn($ListView1, "test", 60, 1)
         _GUICtrlListView_AddColumn($ListView1, "test", 120, 1)
                 _GUICtrlListView_AddColumn($ListView1, "test", 180, 1)
                 _GUICtrlListView_AddColumn($ListView1, "test", 240, 1)
;-------------------------------------
                _GUICtrlListView_AddItem($ListView1, "test",0)
                _GUICtrlListView_AddSubItem($ListView1, 0, "test1", 1, 1)
                _GUICtrlListView_AddSubItem($ListView1, 0, "test2", 2, 2)
GUICtrlSetOnEvent(-1, "ListView1Click")


$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
_GUICtrlStatusBar_SetMinHeight($StatusBar1, 9)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $hquery, $aRow, $sqlit_ok, $ListView1,$date,$dates1,$dates2,$da

$date1 = GUICtrlCreateDate("", 200, 400, 100, 20,$DTS_SHORTDATEFORMAT)  ;日历






$title = "SQLIT测式"
$Sqlit_path = "test.db"
_SQLite_Startup() ;加载Sqlit.dll

if Not FileExists($Sqlit_path) Then
        SQLCreate()
EndIf

While 1
        Sleep(100)
WEnd


Func SQLCreate()
     _SQLite_Open($Sqlit_path)
         _SQLite_Exec(-1,"Create Table If NOT Exists Audit(id integer primary key autoincrement,dates Text,datess Test,datesss Test);")
         _SQLite_Close()
EndFunc

Func SQLwrite()
         $date=GUICtrlRead($date1)
         $dates1 = $date
         $dates2 = $date
        _SQLite_Open($Sqlit_path)
        _SQLite_Exec(-1,"insert into Audit (dates,datess,datesss) values ('"& $date &"','"& $dates1 &"','"& $dates2 &"');")
                MsgBox(4096, "write", "insert into Audit (dates,datess,datesss) values ('"& $date &"','"& $dates1 &"','"& $dates2 &"');", 5)
        _SQLite_Close()
EndFunc

Func SQLread()
        
                                
                                
     _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1))
         _SQLite_Open($Sqlit_path)
         _SQLite_Query(-1,"SELECT * FROM Audit  ORDER BY id ASC;", $hquery)
         While _SQLite_FetchData($hquery, $aRow) = $SQLITE_OK
                 ;_GUICtrlListView_AddItem($ListView1, $aRow[0],0)
                                  GUICtrlCreateListViewItem ( $aRow[0]&"|"& $aRow[1]&"|"& $aRow[2]& "|"& $aRow[3],$ListView1)
                 ;_GUICtrlListView_AddSubItem($ListView1, 0, "Row 0: Col 0", 0)
                 ;_GUICtrlListView_AddSubItem($ListView1, 0, "Row 2: Col 2", 1)
                 ;_GUICtrlListView_AddSubItem($ListView1, 0, "Row 3: Col 3", 2)
                 ;_GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow[0]), $aRow[1], 1)
                 ;_GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow[0]), $aRow[2], 2)
                 ;_GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow[0]), $aRow[3], 3)
                 ;MsgBox(4096, "read", GUICtrlRead($aRow[0]), 1)
         WEnd
         _SQLite_Close()
EndFunc

Func Button1Click()
     SQLwrite()
         SQLread()
        ;MsgBox(4096, "Button1Click", "write", 2)
EndFunc

Func Button2Click()
        

         SQLread()

                                
        ;MsgBox(4096, "Button2Click", "read", 2)
EndFunc

Func Form1Close()
exit
EndFunc

Func Form1Restore()

EndFunc

Func ListView1Click()
                ;MsgBox(4096, "ListView1Click", "test", 1)
EndFunc

本帖子中包含更多资源

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

×
发表于 2010-7-15 05:49:46 | 显示全部楼层
31-35行_GUICtrlListView_AddColumn.....
如下就全部居中了..
  _GUICtrlListView_AddColumn($ListView1, "test", 50, 2)
         _GUICtrlListView_AddColumn($ListView1, "test1", 60, 2)
         _GUICtrlListView_AddColumn($ListView1, "test2", 120, 2)
                 _GUICtrlListView_AddColumn($ListView1, "test3", 180, 2)
                 _GUICtrlListView_AddColumn($ListView1, "test4", 240, 2)


注意看帮助,用法:
#Include <GuiListView.au3>
_GUICtrlListView_AddColumn($hWnd, $sText[, $iWidth = 50[, $iAlign = -1[, $iImage = -1[, $fOnRight = False]]]])


&#160;

参数

$hWnd
控件句柄
$sText
列标题文本
$iWidth
列宽(象素)
$iAlign
标题栏与子项文本对齐方式 0 - 左对齐 1 - 右对齐 2 - 居中对齐
$iImage
图像列内的图像索引(从 0 开始)
$fOnRight
如果为真, 列内图像显示在文本的右边

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

 楼主| 发表于 2010-7-15 11:05:58 | 显示全部楼层
谢谢
 楼主| 发表于 2010-7-15 11:11:02 | 显示全部楼层
本帖最后由 lllangxx 于 2010-7-15 14:35 编辑

还有请问第 95 -102 行 部分如果用注释部分方法 而不用 GUICtrlCreateListViewItem  来实现 读取显示时间会 有空行显示的不正常问题  是怎没回事?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-22 01:43 , Processed in 0.094454 second(s), 26 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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