Dave's Brain

Browse - programming tips - win32 select full row when clicking

Date: 2009oct6
OS: Windows
Platform: MFC
Language: C/C++

Q.  A row is only selected when I click on the label (left item)
in my report mode list control (CListCtrl).  Is there a way to fix this?

A.  There are a number of ways to do this but the best is to enable LVS_EX_FULLROWSELECT like this:

	void EnableNativeFullRowSelect(CListCtrl &list)
	{
		list.SetExtendedStyle(list.GetExtendedStyle() | LVS_EX_FULLROWSELECT); 
	}


	// Example use
	BOOL CMyDlg::OnInitDialog() 
	{
		CDialog::OnInitDialog();

		EnableNativeFullRowSelect(m_MyList);

		// ...
	
		return TRUE;
	}
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.