在有一个带有复选框的 Listview 时,您如何以编程方式设置所有要检查的项目?
问问题
676 次
1 回答
3
Listview checkbox state is set through the state image bits of the item state. You can change item states with the LVM_SETITEMSTATE
message, and can apply a change to all items by passing -1 as the index.
// The state-image index values:
// 1 for the "unchecked" (cleared) state-image
// 2 for the "checked" state-image
int iState = 2;
LVITEM lvi;
lvi.stateMask = LVIS_STATEIMAGEMASK;
lvi.state = INDEXTOSTATEIMAGEMASK(iState);
SendMessage(hwndListView, LVM_SETITEMSTATE, -1, (LPARAM)&lvi);
于 2013-07-11T19:50:13.220 回答