GUICtrlCreateList "text", left, top [, width [, height [, style [, exStyle]]]] Parameters text text hiện trị sẵn trên control left tọa độ X width chiều rộng height chiều cao style kiể
Trang 1Function Reference
GUICtrlCreateList
tạo một List control cho GUI để chọn
GUICtrlCreateList ( "text", left, top [, width [, height [, style [, exStyle]]]] )
Parameters
text text hiện trị sẵn trên control
left tọa độ X
width chiều rộng
height chiều cao
style
kiểu xem thêm GUI Control Styles Appendix
default ( -1) : $LBS_SORT, $WS_BORDER, $WS_VSCROLL forced styles : $WS_TABSTOP, $LBS_NOTIFY
exStyle kiểu mở rộng xem Extended Style Table
Return Value
Success: trả lại ControlID
Failure: Returns 0
Remarks
để lấy giá trị ddang đc chọn của control ta dùng GUICtrlRead
để đặt các thuộc tính cho control ta dùng GUICtrlSet
The different list entries that can be selected can be set with GUICtrlSetData
Trang 2có thể đặt đc tối ta bao nhiêu item nhờ hàm GUICtrlSetLimit
để sử dụng nhiều kiểu trong style ta dùng BitOr($GUI_SS_DEFAULT_LIST,
newstyle, )
để có thể dùng đc các biến trên ta cần phải khai báo thư viện #include
<ListBoxConstants.au3> in your script
Default resizing is $GUI_DOCKAUTO size and position will occur
Related
GUICoordMode (Option), GUICtrlSetData, GUICtrlSetLimit, GUICtrlSet , GUIGetMsg
Example
#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
Example()
Func Example()
Local $MESSAGE = "The following buttons have been clicked"
Local $add, $clear, $mylist, $close, $msg
GUICreate("My GUI list") ; will create a dialog box that when displayed is centered
$add = GUICtrlCreateButton("Add", 64, 32, 75, 25)
$clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25)
$mylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97) GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
GUICtrlSetData(-1, $MESSAGE)
$close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25)
GUISetState()
Trang 3$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
Case $msg = $add
GUICtrlSetData($mylist, "You clicked button No1|")
Case $msg = $clear
GUICtrlSetData($mylist, "")
Case $msg = $close
MsgBox(0, "", "the closing button has been clicked", 2)
Exit
EndSelect
WEnd
EndFunc ;==>Example
Function Reference
GUICtrlCreateListView
Creates a ListView control for the GUI
GUICtrlCreateListView ( "text", left, top [, width [, height [, style [, exStyle]]]] )
Parameters
text text hiện trị sẵn trên control
left tọa độ X
width chiều rộng
height chiều cao
style kiểu xem thêm GUI Control Styles Appendix
Trang 4default (-1) : $LVS_SHOWSELALWAYS, $LVS_SINGLESEL forced style : $LVS_REPORT
exStyle kiểu mở rộng xem Extended Style Table
Return Value
Success: trả lại ControlID
Failure: Returns 0
Remarks
để thêm item cho control ta dùng GUICtrlCreateListViewItem
Các ListView sẽ xuất hiện theo mặc định như trong Explorer xem "Details" (kiểu LVS_REPORT là bắt buộc)
Bạn có thể kiểm soát kích thước ban đầu cột của padding để trống cột tiêu đề định nghĩa Các cột có thể được gia hạn trong thời gian GUICtrlCreateListViewItem theo mục kích cỡ Kích cỡ của một cột sẽ được tính đến khoảng 25 ký tự Không
có thay đổi kích thước sẽ được thực hiện trong thời gian một cập nhật của
GUICtrlSetData
để tạo ra một ListView với Icon-, SmallIcon- hay List-style ta cần tạo
GUICtrlSetStyle với các kiểu $LVS_ICON, $LVS_LIST hay
$LVS_SMALLICON
để sắp xếp theo thứ tự ta có thể click vào tên cột
để lựa chọn đc cả dòng ta dùng extended style LVS_EX_FULLROWSELECT
để sử dụng nhiều kiểu trong style ta dùng
BitOr($GUI_SS_DEFAULT_LISTVIEW, newstyle, )
để có thể dùng đc các biến trên ta cần phải khai báo thư viện #include
<ListViewConstants.au3> in your script
Trang 5đặc biệt flag $GUI_BKCOLOR_LV_ALTERNATE có thể dùng với
control Listview để đặt mầu nền của ListviewItems
The odd lines will get the color set by GUICtrlSetBkColor of the Listview control The even lines will get the color set by GUICtrlSetBkColor of the ListviewItem control
Related
GUICtrlCreateListViewItem, GUICtrlRegisterListViewSort, GUICoordMode (Option), GUICtrlSetData, GUIGetMsg, GUIDataSeparatorChar (Option)
Example
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Example()
Func Example()
Local $listview, $button, $item1, $item2, $item3, $input1, $msg
GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES) GUISetBkColor(0x00E0FFFF) ; will change background color
$listview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200,
150);,$LVS_SORTDESCENDING)
$button = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
$item1 = GUICtrlCreateListViewItem("item2|col22|col23", $listview)
$item2 = GUICtrlCreateListViewItem("item1|col12|col13", $listview)
$item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview)
$input1 = GUICtrlCreateInput("", 20, 200, 150)
GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping GUISetState()
GUICtrlSetData($item2, "ITEM1")
Trang 6GUICtrlSetData($item3, "||COL33") GUICtrlDelete($item1)