Disableing items in CLIstCtrl

Hello,

    Is there a way to disable an item in CListCtrl so that the item is gray
out and a user won't be able to select it.

Thank You!


0
horvathr (32)
4/15/2005 3:03:17 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
824 Views

Similar Articles

[PageSpeed] 38

At this point I think you have to go to an owner-draw list control and do it yourself. You
also have to prevent the selection from happening.
				joe

On Fri, 15 Apr 2005 11:03:17 -0400, "Ririko Horvath" <horvathr@securemethods.com> wrote:

>Hello,
>
>    Is there a way to disable an item in CListCtrl so that the item is gray
>out and a user won't be able to select it.
>
>Thank You!
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
4/17/2005 3:36:59 AM

Ririko Horvath wrote:
> Hello,
> 
>     Is there a way to disable an item in CListCtrl so that the item is gray
> out and a user won't be able to select it.

You will have to derive from CListCtrl and override DrawItem. There is 
an example of what this entails in the CListBox::DrawItem. There are 
examples all over the web for CListCtrl. You will have to keep track of 
what is enabled yourself, you can use the data member of the item.

You will want to handle LVN_ITEMCHANGING. If you have disabled it, set 
*pResult to 1. This will keep the item from changing to selected. This, 
even if you don't draw it selected, so the selected flag doesn't get set.

Best, Dan.

0
public21 (290)
4/22/2005 6:21:56 PM
Reply:

Similar Artilces: