CListCtrl::SetItemText()用法和listctrl 设置风格

本文介绍了MFC中CListCtrl::SetItemText函数的使用方法,包括参数说明和示例代码,并展示了如何设置列表控件的各种显示风格。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SetItemText用法

CListCtrl::SetItemText

BOOL SetItemText( int nItem, int nSubItem, LPTSTR lpszText );

Return Value

Nonzero if successful; otherwise zero.

Parameters

nItem

Index of the item whose text is to be set.

nSubItem

Index of the subitem, or zero to set the item label.

lpszText

Pointer to a string that contains the new item text.

例子:

m_list1.InsertItem(0,"");
 m_list1.SetItemText(0,0 , "1、培训时间");
 m_list1.SetItemText(0,1 , "[  ]");

listctrl 设置风格

//获得原有风格
DWORD dwStyle = ::GetWindowLong(m_listctrl.m_hWnd, GWL_STYLE);
dwStyle &= ~(LVS_TYPEMASK);
dwStyle &= ~(LVS_EDITLABELS);
//设置新风格
SetWindowLong(m_listctrl.m_hWnd, GWL_STYLE,dwStyle, |LVS_REPORT | LVS_NOLABELWRAP | LVS_SHOWSELALWAYS);
//设置扩展风格
DWORD styles = LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_CHECKBOXES;
ListView_SetExtendedListViewStyleEx(m_listctrl.m_hWnd, styles, styles );

其中LVS_EX_FULLROWSELECT 就是前面说得整行选中
LVS_EX_GRIDLINES 网格线(只适用与report风格的listctrl)
LVS_EX_CHECKBOXES 前面加个checkbox
pListCtrl->SetExtendedStyle( m_listctrl.GetExtendedStyle() | LVS_EX_SUBITEMIMAGES);

转载于:https://www.cnblogs.com/rrll/archive/2011/08/11/2134499.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值