檢視原始碼 wxListCtrl (wx v2.4.3)
列表控制項以多種格式呈現列表:列表檢視、報表檢視、圖示檢視和小圖示檢視。
在任何情況下,元素都從零開始編號。對於所有這些模式,項目都儲存在控制項中,並且必須使用 insertItem/4
方法將其加入。
報表檢視的一個特殊情況與列表控制項的其他模式有很大的不同,它是一個虛擬控制項,其中項目資料(包括文字、圖像和屬性)由主程式管理,並且僅在需要時由控制項本身請求,這允許控制項擁有數百萬個項目而不會消耗太多記憶體。若要使用虛擬列表控制項,您必須先使用 setItemCount/2
,並覆寫至少 wxListCtrl::OnGetItemText
(在 wx 中未實作)(並可選擇覆寫 wxListCtrl::OnGetItemImage
(在 wx 中未實作)或 wxListCtrl::OnGetItemColumnImage
(在 wx 中未實作)和 wxListCtrl::OnGetItemAttr
(在 wx 中未實作)),以便在控制項請求時傳回有關項目的資訊。
虛擬列表控制項可以用作一般控制項,但不會發生可能與控制項中項目數量成正比耗費時間的操作 - 這是允許擁有實際上無限數量的項目所必需的。例如,在多重選擇虛擬列表控制項中,當一次選取多個項目時,不會傳送選取項目,因為這可能意味著要迭代所有項目。
在相應的範例中顯示了許多 wxListCtrl
功能的使用方式。
若要攔截來自列表控制項的事件,請使用 wxListEvent
中描述的事件表巨集。
wxMac 注意事項
:從 wxWidgets 2.8 開始,wxListCtrl
對於報表模式使用原生實作,而對於其他模式則使用泛型實作。您也可以透過設定 mac.listctrl.always_use_generic
系統選項(請參閱 wxSystemOptions
)為 1,對報表模式使用泛型實作。
樣式
此類別支援下列樣式
wxLC_LIST:多欄列表檢視,可選擇使用小圖示。欄會自動計算,也就是說,您不需要像
wxLC_REPORT
中那樣設定欄。換句話說,列表會換行,這與wxListBox
不同。wxLC_REPORT:單欄或多欄報表檢視,可選擇使用標頭。
wxLC_VIRTUAL:應用程式會按需提供項目文字。只能與
wxLC_REPORT
一起使用。wxLC_ICON:大型圖示檢視,可選擇使用標籤。
wxLC_SMALL_ICON:小型圖示檢視,可選擇使用標籤。
wxLC_ALIGN_TOP:圖示對齊頂部。Win32 預設值,僅限 Win32。
wxLC_ALIGN_LEFT:圖示對齊左側。
wxLC_AUTOARRANGE:圖示會自行排列。僅限 Win32。
wxLC_EDIT_LABELS:標籤可編輯:應用程式會在編輯開始時收到通知。
wxLC_NO_HEADER:報表模式中沒有標頭。
wxLC_SINGLE_SEL:單一選取 (預設為多重選取)。
wxLC_SORT_ASCENDING:以遞增順序排序。(您仍然必須在
sortItems/2
中提供比較回呼。)wxLC_SORT_DESCENDING:以遞減順序排序。(您仍然必須在
sortItems/2
中提供比較回呼。)wxLC_HRULES:在報表模式中的列之間繪製淺色水平線。
wxLC_VRULES:在報表模式中的欄之間繪製淺色垂直線。
請參閱
此類別繼承自,並且可以使用來自
wxWidgets 文件:wxListCtrl
事件
從此類別發出的事件類型
摘要
函式
排列圖示或小圖示檢視中的項目。
設定與控制項相關聯的影像列表並取得其所有權(即
刪除所有項目和所有欄。
刪除列表控制項中的所有項目。
刪除指定的項目。
銷毀物件
開始編輯指定項目的標籤。
確保此項目可見。
從 start
或開頭開始(如果 start
為 -1),在指定的方向尋找最接近此位置的項目。
取得有關此欄的資訊。
傳回欄數。
取得欄寬度(僅限報表檢視)。
取得列表控制項的可見區域中可垂直容納的項目數(列表或報表檢視)或列表控制項中的項目總數(圖示或小圖示檢視)。
傳回目前用於編輯標籤的編輯控制項。
傳回指定的影像列表。
取得有關項目的資訊。
傳回此項目的色彩。
傳回列表控制項中的項目數。
取得與此項目關聯的應用程式定義資料。
傳回項目的字型。
傳回圖示或小圖示檢視中項目的位置。
傳回表示項目大小和位置的矩形,以實體座標表示。
擷取圖示之間以像素為單位的間距:水平間距以 {Width,Height} 物件的 x
元件傳回,垂直間距以其 y
元件傳回。
取得此項目的項目文字。
傳回此項目的色彩。
搜尋具有指定幾何形狀或狀態的項目,從 item
開始,但不包括 item
本身。
傳回列表控制項中選取項目的數量。
取得列表控制項的文字色彩。
取得列表或報表檢視中最高可見項目的索引。
傳回控制項中所有項目佔用的矩形。
判斷指定點上是否有項目(如果有的話),並在 flags
中提供詳細資訊。
對於報表檢視模式(僅限),插入欄。
對於報表檢視模式(僅限),插入欄。
插入項目,如果成功則傳回新項目的索引,否則傳回 -1。
插入字串項目。
插入影像/字串項目。
重新繪製指定的 item
。
重新繪製 itemFrom
和 itemTo
之間的項目。
捲動列表控制項。
設定背景色彩。
設定有關此欄的資訊。
設定與控制項相關聯的影像列表。
設定項目的資料。
在特定欄設定項目字串欄位。
設定此項目的背景色彩。
設定與項目關聯的影像。
此方法只能與虛擬列表控制項一起使用。
將應用程式定義的資料與此項目關聯。
設定項目的字型。
設定與項目關聯的未選取和選取影像。
設定圖示或小圖示檢視中項目的位置。
設定此項目的項目文字。
設定此項目的色彩。
新增或移除單一視窗樣式。
設定列表控制項的文字色彩。
設定整個視窗樣式,並刪除所有項目。
類型
-type wxListCtrl() :: wx:wx_object().
函式
-spec arrange(This) -> boolean() when This :: wxListCtrl().
等同於 arrange(This, [])
。
-spec arrange(This, [Option]) -> boolean() when This :: wxListCtrl(), Option :: {flag, integer()}.
排列圖示或小圖示檢視中的項目。
這僅在 Win32 上有效。flag
是下列其中一項
wxLIST_ALIGN_DEFAULT:預設對齊方式。
wxLIST_ALIGN_LEFT:對齊控制項的左側。
wxLIST_ALIGN_TOP:對齊控制項的頂部。
wxLIST_ALIGN_SNAP_TO_GRID:貼齊格線。
-spec assignImageList(This, ImageList, Which) -> ok when This :: wxListCtrl(), ImageList :: wxImageList:wxImageList(), Which :: integer().
設定與控制項相關聯的影像列表並取得其所有權(即
與使用 setImageList/3
時不同,控制項將在銷毀時刪除列表。which
是 wxIMAGE_LIST_NORMAL
、wxIMAGE_LIST_SMALL
、wxIMAGE_LIST_STATE
(最後一個未實作)之一。
請參閱:setImageList/3
-spec clearAll(This) -> ok when This :: wxListCtrl().
刪除所有項目和所有欄。
注意:在所有平台上,這會發送類型為 wxEVT_LIST_DELETE_ALL_ITEMS
的事件。
-spec create(This, Parent) -> boolean() when This :: wxWindow:wxWindow(), Parent :: wxWindow:wxWindow().
-spec create(This, Parent, [Option]) -> boolean() when This :: wxWindow:wxWindow(), Parent :: wxWindow:wxWindow(), Option :: {winid, integer()} | {pos, {X :: integer(), Y :: integer()}} | {size, {W :: integer(), H :: integer()}} | {style, integer()} | {validator, wx:wx_object()} | {onGetItemText, function()} | {onGetItemAttr, function()} | {onGetItemColumnImage, function()}.
-spec deleteAllItems(This) -> boolean() when This :: wxListCtrl().
刪除列表控制項中的所有項目。
此函式不會
發送 wxEVT_LIST_DELETE_ITEM
事件,因為從控制項中刪除多個項目會太慢(與 deleteItem/2
不同),但如果控制項不是空的,它會發送特殊的 wxEVT_LIST_DELETE_ALL_ITEMS
事件。如果它已經是空的,則不會執行任何操作,也不會發送任何事件。
回傳值:如果項目已成功刪除,或控制項已為空,則傳回 true;如果在刪除項目時發生錯誤,則傳回 false。
-spec deleteColumn(This, Col) -> boolean() when This :: wxListCtrl(), Col :: integer().
刪除欄。
-spec deleteItem(This, Item) -> boolean() when This :: wxListCtrl(), Item :: integer().
刪除指定的項目。
此函式會為正在刪除的項目發送 wxEVT_LIST_DELETE_ITEM
事件。
請參閱:deleteAllItems/1
-spec destroy(This :: wxListCtrl()) -> ok.
銷毀物件
-spec editLabel(This, Item) -> wxTextCtrl:wxTextCtrl() when This :: wxListCtrl(), Item :: integer().
開始編輯指定項目的標籤。
此函式會產生 EVT_LIST_BEGIN_LABEL_EDIT
事件,該事件可以被否決,這樣就不會出現用於就地編輯的文字控制項。
如果使用者變更了標籤(即,他/她沒有按下 ESC 或在未變更的情況下離開文字控制項),則會發送 EVT_LIST_END_LABEL_EDIT
事件,該事件也可以被否決。
-spec ensureVisible(This, Item) -> boolean() when This :: wxListCtrl(), Item :: integer().
確保此項目可見。
-spec findItem(This, Start, Str) -> integer() when This :: wxListCtrl(), Start :: integer(), Str :: unicode:chardata().
-spec findItem(This, Start, Str, [Option]) -> integer() when This :: wxListCtrl(), Start :: integer(), Str :: unicode:chardata(), Option :: {partial, boolean()}; (This, Start, Pt, Direction) -> integer() when This :: wxListCtrl(), Start :: integer(), Pt :: {X :: integer(), Y :: integer()}, Direction :: integer().
從 start
或開頭開始(如果 start
為 -1),在指定的方向尋找最接近此位置的項目。
回傳值:如果有的話,則傳回下一個符合的項目,否則傳回 -1
(wxNOT_FOUND)。
-spec getColumn(This, Col, Item) -> boolean() when This :: wxListCtrl(), Col :: integer(), Item :: wxListItem:wxListItem().
取得有關此欄的資訊。
請參閱 setItem/5
以取得更多資訊。
-spec getColumnCount(This) -> integer() when This :: wxListCtrl().
傳回欄數。
-spec getColumnWidth(This, Col) -> integer() when This :: wxListCtrl(), Col :: integer().
取得欄寬度(僅限報表檢視)。
-spec getCountPerPage(This) -> integer() when This :: wxListCtrl().
取得列表控制項的可見區域中可垂直容納的項目數(列表或報表檢視)或列表控制項中的項目總數(圖示或小圖示檢視)。
-spec getEditControl(This) -> wxTextCtrl:wxTextCtrl() when This :: wxListCtrl().
傳回目前用於編輯標籤的編輯控制項。
如果沒有正在編輯的標籤,則傳回 NULL。
注意:目前僅針對 wxMSW 和通用版本實作,不適用於原生 macOS 版本。
-spec getImageList(This, Which) -> wxImageList:wxImageList() when This :: wxListCtrl(), Which :: integer().
傳回指定的影像列表。
which
可以是下列其中之一:
wxIMAGE_LIST_NORMAL:正常的(大圖示)影像清單。
wxIMAGE_LIST_SMALL:小圖示影像清單。
wxIMAGE_LIST_STATE:使用者定義的狀態影像清單(未實作)。
-spec getItem(This, Info) -> boolean() when This :: wxListCtrl(), Info :: wxListItem:wxListItem().
取得有關項目的資訊。
請參閱 setItem/5
以取得更多資訊。
您必須在呼叫此方法之前呼叫 info.SetId()
來設定您感興趣的項目 ID,並使用指示您需要從 info
擷取哪些欄位的旗標呼叫 info.SetMask()
。
-spec getItemBackgroundColour(This, Item) -> wx:wx_colour4() when This :: wxListCtrl(), Item :: integer().
傳回此項目的色彩。
如果項目沒有特定的顏色,則會傳回無效的顏色(而不是控制項本身的預設背景控制項)。
-spec getItemCount(This) -> integer() when This :: wxListCtrl().
傳回列表控制項中的項目數。
-spec getItemData(This, Item) -> integer() when This :: wxListCtrl(), Item :: integer().
取得與此項目關聯的應用程式定義資料。
-spec getItemFont(This, Item) -> wxFont:wxFont() when This :: wxListCtrl(), Item :: integer().
傳回項目的字型。
-spec getItemPosition(This, Item) -> Result when Result :: {Res :: boolean(), Pos :: {X :: integer(), Y :: integer()}}, This :: wxListCtrl(), Item :: integer().
傳回圖示或小圖示檢視中項目的位置。
-spec getItemRect(This, Item, [Option]) -> Result when Result :: {Res :: boolean(), Rect :: {X :: integer(), Y :: integer(), W :: integer(), H :: integer()}}, This :: wxListCtrl(), Item :: integer(), Option :: {code, integer()}.
傳回表示項目大小和位置的矩形,以實體座標表示。
code
是 wxLIST_RECT_BOUNDS、wxLIST_RECT_ICON、wxLIST_RECT_LABEL 其中之一。
-spec getItemSpacing(This) -> {W :: integer(), H :: integer()} when This :: wxListCtrl().
擷取圖示之間以像素為單位的間距:水平間距以 {Width,Height} 物件的 x
元件傳回,垂直間距以其 y
元件傳回。
-spec getItemState(This, Item, StateMask) -> integer() when This :: wxListCtrl(), Item :: integer(), StateMask :: integer().
取得項目狀態。
如需狀態旗標的清單,請參閱 setItem/5
。stateMask
指示哪些狀態旗標是您感興趣的。
-spec getItemText(This, Item) -> unicode:charlist() when This :: wxListCtrl(), Item :: integer().
-spec getItemText(This, Item, [Option]) -> unicode:charlist() when This :: wxListCtrl(), Item :: integer(), Option :: {col, integer()}.
取得此項目的項目文字。
-spec getItemTextColour(This, Item) -> wx:wx_colour4() when This :: wxListCtrl(), Item :: integer().
傳回此項目的色彩。
如果項目沒有特定的顏色,則會傳回無效的顏色(而不是控制項本身的預設前景控制項,因為這樣無法區分具有與目前控制項前景相同顏色的項目,以及具有預設顏色,因此始終具有與控制項相同顏色的項目)。
-spec getNextItem(This, Item) -> integer() when This :: wxListCtrl(), Item :: integer().
-spec getNextItem(This, Item, [Option]) -> integer() when This :: wxListCtrl(), Item :: integer(), Option :: {geometry, integer()} | {state, integer()}.
搜尋具有指定幾何形狀或狀態的項目,從 item
開始,但不包括 item
本身。
如果 item
為 -1,則會傳回第一個符合指定旗標的項目。傳回 item
之後第一個具有給定狀態的項目,如果找不到此類項目,則傳回 -1。此函式可用於尋找控制項中所有選取的項目,如下所示:
geometry
可以是下列其中之一:
wxLIST_NEXT_ABOVE:搜尋指定項目上方的項目。
wxLIST_NEXT_ALL:依索引搜尋後續項目。
wxLIST_NEXT_BELOW:搜尋指定項目下方的項目。
wxLIST_NEXT_LEFT:搜尋指定項目左側的項目。
wxLIST_NEXT_RIGHT:搜尋指定項目右側的項目。
注意:此參數目前僅在 wxMSW 中支援,並在其他平台上忽略。
state
可以是下列項目的位元清單:
wxLIST_STATE_DONTCARE:不在意狀態是什麼。
wxLIST_STATE_DROPHILITED:項目表示它是拖放目標。
wxLIST_STATE_FOCUSED:項目具有焦點。
wxLIST_STATE_SELECTED:項目已選取。
wxLIST_STATE_CUT:項目已選取為剪下和貼上操作的一部分。
-spec getSelectedItemCount(This) -> integer() when This :: wxListCtrl().
傳回列表控制項中選取項目的數量。
-spec getTextColour(This) -> wx:wx_colour4() when This :: wxListCtrl().
取得列表控制項的文字色彩。
-spec getTopItem(This) -> integer() when This :: wxListCtrl().
取得列表或報表檢視中最高可見項目的索引。
-spec getViewRect(This) -> {X :: integer(), Y :: integer(), W :: integer(), H :: integer()} when This :: wxListCtrl().
傳回控制項中所有項目佔用的矩形。
換句話說,如果控制項的客戶端大小等於此矩形的大小,則不需要捲軸,也不會留下任何可用空間。
請注意,此函式僅在圖示和小圖示檢視中有效,在清單或報表檢視中無效(這是原生 Win32 控制項的限制)。
-spec hitTest(This, Point) -> Result when Result :: {Res :: integer(), Flags :: integer(), PtrSubItem :: integer()}, This :: wxListCtrl(), Point :: {X :: integer(), Y :: integer()}.
判斷指定點上是否有項目(如果有的話),並在 flags
中提供詳細資訊。
如果指定點沒有項目,則傳回項目的索引或 wxNOT_FOUND
。
flags
將會是下列旗標的組合:
wxLIST_HITTEST_ABOVE:在控制項客戶端區域的上方。
wxLIST_HITTEST_BELOW:在控制項客戶端區域的下方。
wxLIST_HITTEST_TOLEFT:在控制項客戶端區域的左側。
wxLIST_HITTEST_TORIGHT:在控制項客戶端區域的右側。
wxLIST_HITTEST_NOWHERE:在控制項客戶端區域內,但不在項目上方。
wxLIST_HITTEST_ONITEMICON:在項目的圖示上方。
wxLIST_HITTEST_ONITEMLABEL:在項目的文字上方。
wxLIST_HITTEST_ONITEMSTATEICON:在項目的核取方塊上方。
wxLIST_HITTEST_ONITEM:
wxLIST_HITTEST_ONITEMICON
、wxLIST_HITTEST_ONITEMLABEL
、wxLIST_HITTEST_ONITEMSTATEICON
的組合。
如果 ptrSubItem
不是 NULL 且 wxListCtrl
處於報表模式,則也會提供子項目(或欄)編號。此功能僅在 2.7.0 或更高版本中可用,並且目前僅在 wxMSW 下實作,並且需要在主機系統上至少具有版本 4.70 的 comctl32.dll,否則儲存在 ptrSubItem
中的值將始終為 -1。若要將此功能編譯到 wxWidgets 程式庫中,您需要有權存取 Microsoft 提供的版本 4.70 的 commctrl.h。
-spec insertColumn(This, Col, Heading) -> integer() when This :: wxListCtrl(), Col :: integer(), Heading :: unicode:chardata(); (This, Col, Info) -> integer() when This :: wxListCtrl(), Col :: integer(), Info :: wxListItem:wxListItem().
對於報表檢視模式(僅限),插入欄。
如需更多詳細資訊,請參閱 setItem/5
。另請參閱 insertColumn/4
多載,以取得通常更方便的替代方法,以及此方法如何解釋項目寬度的說明。
-spec insertColumn(This, Col, Heading, [Option]) -> integer() when This :: wxListCtrl(), Col :: integer(), Heading :: unicode:chardata(), Option :: {format, integer()} | {width, integer()}.
對於報表檢視模式(僅限),插入欄。
在報表檢視模式中,於給定的位置插入新的欄,並指定其最常見的屬性。
請注意,若要為欄設定影像,您需要使用 insertColumn/4
多載,並在項目遮罩中指定 ?wxLIST_MASK_IMAGE。
回傳值:插入欄的索引,如果新增失敗則傳回 -1。
-spec insertItem(This, Info) -> integer() when This :: wxListCtrl(), Info :: wxListItem:wxListItem().
插入項目,如果成功則傳回新項目的索引,否則傳回 -1。
-spec insertItem(This, Index, ImageIndex) -> integer() when This :: wxListCtrl(), Index :: integer(), ImageIndex :: integer(); (This, Index, Label) -> integer() when This :: wxListCtrl(), Index :: integer(), Label :: unicode:chardata().
插入字串項目。
-spec insertItem(This, Index, Label, ImageIndex) -> integer() when This :: wxListCtrl(), Index :: integer(), Label :: unicode:chardata(), ImageIndex :: integer().
插入影像/字串項目。
-spec new() -> wxListCtrl().
-spec new(Parent) -> wxListCtrl() when Parent :: wxWindow:wxWindow().
-spec new(Parent, [Option]) -> wxListCtrl() when Parent :: wxWindow:wxWindow(), Option :: {winid, integer()} | {pos, {X :: integer(), Y :: integer()}} | {size, {W :: integer(), H :: integer()}} | {style, integer()} | {validator, wx:wx_object()} | {onGetItemText, function()} | {onGetItemAttr, function()} | {onGetItemColumnImage, function()}.
-spec refreshItem(This, Item) -> ok when This :: wxListCtrl(), Item :: integer().
重新繪製指定的 item
。
這僅適用於虛擬清單控制項,因為在沒有呼叫此函式的情況下,即使基礎資料發生變更,項目的顯示值也不會變更。
請參閱:refreshItems/3
-spec refreshItems(This, ItemFrom, ItemTo) -> ok when This :: wxListCtrl(), ItemFrom :: integer(), ItemTo :: integer().
重新繪製 itemFrom
和 itemTo
之間的項目。
起始項目必須小於或等於結束項目。
就像 refreshItem/2
一樣,這僅適用於虛擬清單控制項。
-spec scrollList(This, Dx, Dy) -> boolean() when This :: wxListCtrl(), Dx :: integer(), Dy :: integer().
捲動列表控制項。
如果在圖示、小圖示或報表檢視模式中,dx
指定要捲動的像素數。如果在清單檢視模式中,dx
指定要捲動的欄數。dy
始終指定垂直捲動的像素數。
注意:此方法目前僅在 Windows 版本中實作。
-spec setBackgroundColour(This, Col) -> boolean() when This :: wxListCtrl(), Col :: wx:wx_colour().
設定背景色彩。
請注意,wxWindow:getBackgroundColour/1
函式(屬於 wxWindow
基底類別)可用於擷取目前的背景顏色。
-spec setColumn(This, Col, Item) -> boolean() when This :: wxListCtrl(), Col :: integer(), Item :: wxListItem:wxListItem().
設定有關此欄的資訊。
請參閱 setItem/5
以取得更多資訊。
-spec setColumnWidth(This, Col, Width) -> boolean() when This :: wxListCtrl(), Col :: integer(), Width :: integer().
設定欄寬度。
width
可以是像素寬度或 wxLIST_AUTOSIZE
(-1) 或 wxLIST_AUTOSIZE_USEHEADER
(-2)。
wxLIST_AUTOSIZE
會將欄的大小調整為其最長項目的長度。
wxLIST_AUTOSIZE_USEHEADER
會將欄的大小調整為標頭的長度 (Win32) 或 80 像素(其他平台)。
在小圖示或一般圖示檢視中,col
必須為 -1,並且會為所有欄設定欄寬。
-spec setImageList(This, ImageList, Which) -> ok when This :: wxListCtrl(), ImageList :: wxImageList:wxImageList(), Which :: integer().
設定與控制項相關聯的影像列表。
which
是 wxIMAGE_LIST_NORMAL
、wxIMAGE_LIST_SMALL
、wxIMAGE_LIST_STATE
其中之一(最後一個未實作)。
此方法不會取得影像清單的所有權,您必須自行刪除它。
-spec setItem(This, Info) -> boolean() when This :: wxListCtrl(), Info :: wxListItem:wxListItem().
設定項目的資料。
使用 wxListItem
的遮罩和狀態遮罩,您只能變更 wxListCtrl
項目的選定屬性。
回傳值:如果項目已成功更新,則傳回 true;如果更新因某些原因失敗(例如,項目索引無效),則傳回 false。
-spec setItem(This, Index, Column, Label) -> boolean() when This :: wxListCtrl(), Index :: integer(), Column :: integer(), Label :: unicode:chardata().
-spec setItem(This, Index, Column, Label, [Option]) -> boolean() when This :: wxListCtrl(), Index :: integer(), Column :: integer(), Label :: unicode:chardata(), Option :: {imageId, integer()}.
在特定欄設定項目字串欄位。
回傳值:如果項目已成功更新,則傳回 true;如果更新因某些原因失敗(例如,項目索引無效),則傳回 false。
-spec setItemBackgroundColour(This, Item, Col) -> ok when This :: wxListCtrl(), Item :: integer(), Col :: wx:wx_colour().
設定此項目的背景色彩。
此函式僅在報表檢視模式中有效。可以使用 getItemBackgroundColour/2
來擷取顏色。
-spec setItemColumnImage(This, Item, Column, Image) -> boolean() when This :: wxListCtrl(), Item :: integer(), Column :: integer(), Image :: integer().
設定與項目關聯的影像。
在報表檢視中,您可以指定欄。影像是在與清單控制項相關聯的影像清單中的索引。
-spec setItemCount(This, Count) -> ok when This :: wxListCtrl(), Count :: integer().
此方法只能與虛擬列表控制項一起使用。
它用於向控制項指示它包含的項目數。呼叫它之後,主要程式應準備好處理對各種項目回呼(例如 wxListCtrl::OnGetItemText
(在 wx 中未實作))的呼叫,範圍從 0 到 count
的所有項目。
請注意,控制項不一定會在這次呼叫後重新繪製,如果從顯示多個項目的控制項中新增或移除任何在螢幕上不可見的項目,則可能是不希望這樣做,如果確實需要重新整理顯示畫面,您可以手動呼叫 wxWindow:refresh/2
。
-spec setItemData(This, Item, Data) -> boolean() when This :: wxListCtrl(), Item :: integer(), Data :: integer().
將應用程式定義的資料與此項目關聯。
請注意,此函式不能用於將指標與控制項項目建立關聯,請改用 SetItemPtrData()
(在 wx 中未實作)。
-spec setItemFont(This, Item, Font) -> ok when This :: wxListCtrl(), Item :: integer(), Font :: wxFont:wxFont().
設定項目的字型。
-spec setItemImage(This, Item, Image) -> boolean() when This :: wxListCtrl(), Item :: integer(), Image :: integer().
-spec setItemImage(This, Item, Image, [Option]) -> boolean() when This :: wxListCtrl(), Item :: integer(), Image :: integer(), Option :: {selImage, integer()}.
設定與項目關聯的未選取和選取影像。
影像是在與清單控制項相關聯的影像清單中的索引。
-spec setItemPosition(This, Item, Pos) -> boolean() when This :: wxListCtrl(), Item :: integer(), Pos :: {X :: integer(), Y :: integer()}.
設定圖示或小圖示檢視中項目的位置。
僅限 Windows。
-spec setItemState(This, Item, State, StateMask) -> boolean() when This :: wxListCtrl(), Item :: integer(), State :: integer(), StateMask :: integer().
設定項目狀態。
stateMask
是 wxListItem
文件中描述的 wxLIST_STATE_XXX
常數的組合。對於 stateMask
中指定的每個位元,會根據 state
引數是否包含相同的位元,來設定或清除對應的狀態。
因此,若要選取項目,您可以使用,而若要取消選取項目,則應使用
如果可能,請考慮使用 wxListView
,以避免處理這個容易出錯且令人困惑的方法。
另請注意,與只有使用者動作才會產生事件的通常規則相反,此方法在用於選取項目時會產生 wxEVT_LIST_ITEM_SELECTED 事件。
-spec setItemText(This, Item, Text) -> ok when This :: wxListCtrl(), Item :: integer(), Text :: unicode:chardata().
設定此項目的項目文字。
-spec setItemTextColour(This, Item, Col) -> ok when This :: wxListCtrl(), Item :: integer(), Col :: wx:wx_colour().
設定此項目的色彩。
此函式僅在報表檢視中有效。可以使用 getItemTextColour/2
來擷取顏色。
-spec setSingleStyle(This, Style) -> ok when This :: wxListCtrl(), Style :: integer().
-spec setSingleStyle(This, Style, [Option]) -> ok when This :: wxListCtrl(), Style :: integer(), Option :: {add, boolean()}.
新增或移除單一視窗樣式。
-spec setTextColour(This, Col) -> ok when This :: wxListCtrl(), Col :: wx:wx_colour().
設定列表控制項的文字色彩。
-spec setWindowStyleFlag(This, Style) -> ok when This :: wxListCtrl(), Style :: integer().
設定整個視窗樣式,並刪除所有項目。
-spec sortItems(This :: wxListCtrl(), SortCallBack) -> boolean() when SortCallBack :: fun((integer(), integer()) -> integer()).