MFC CListView

void CMyListView::InitializeListView()
{
	/*
	CListCtrl& m_list = GetListCtrl();//得到内置 listctrl 引用	
	LONG lStyle;	
	lStyle = GetWindowLong(m_list.m_hWnd, GWL_STYLE);//获得当前窗口风格	
	lStyle &= ~LVS_TYPEMASK; //清除显示方式	
	lStyle |= LVS_REPORT; //设置窗口风格	
	SetWindowLong(m_list.m_hWnd, GWL_STYLE, lStyle); //设置窗口风格
	DWORD dwStyle = m_list.GetExtendedStyle();	
	//Ñ¡ÖÐijһÐÐʱʹÕûÐиßÁÁ(Ö»ÊÇÓÃÓÚ±¨±í·ç¸ñµÄ listctrl)	
	dwStyle |= LVS_EX_FULLROWSELECT;	
	dwStyle |= LVS_EX_GRIDLINES;//ÍøÂçÏß(Ö»ÊÊÓÃÓÚ±¨±í·ç¸ñlistctrl)	
	m_list.SetExtendedStyle(dwStyle); //设置扩展风格	
	m_list.SetBkColor(RGB(200, 200, 200)); //设置背景颜色	
	m_list.SetTextBkColor(RGB(200, 200, 200)); //设置文字背景颜色	
	m_list.SetTextColor(RGB(10, 10, 80)); //设置文字颜色	
	//插入标题	
	m_list.InsertColumn( 0, "Name", LVCFMT_CENTER, 80 );	
	m_list.InsertColumn( 1, "ID Number", LVCFMT_CENTER, 110 );	
	m_list.InsertColumn( 2, "Sex", LVCFMT_CENTER, 110 );
	*/
	CWaitCursor wc;
	CListCtrl& theListCtrl = GetListCtrl();
	theListCtrl.SetRedraw(FALSE);
	//For the style LVS_EX_FULLROWSELECT, you'll need the following, depending on the OS:
	//Windows NT: Requires version 5.0 or later (or version 4.0 with Internet Explorer 3.0 and later).. 
	//Windows: Requires Windows 98 (or Windows 95 with Internet Explorer 3.0 or later). 
	//Otherwise, you'll need to do ownerdrawn stuff. In that case, see the MFC ROWLIST sample.
	DWORD dwExStyle = LVS_EX_FULLROWSELECT;
	theListCtrl.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, (WPARAM)dwExStyle, (LPARAM)dwExStyle);
	COLORREF crYellow = RGB(240,240,200); //light yellow
	theListCtrl.SetBkColor(crYellow);
	theListCtrl.SetTextBkColor(crYellow);
	theListCtrl.InsertColumn(0, "name");
	theListCtrl.InsertColumn(1, "address");
	theListCtrl.InsertColumn(2, "city");
	theListCtrl.InsertColumn(3, "state");
	theListCtrl.InsertColumn(4, "zip code");
	for(UINT i = 0; i< 5; i++)
		theListCtrl.SetColumnWidth(i, LVSCW_AUTOSIZE_USEHEADER);//根据行的字符串的宽度确定行的宽度
	theListCtrl.SetRedraw(TRUE);
	theListCtrl.Invalidate();
}

  

转载于:https://www.cnblogs.com/thetung/p/3634982.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值