Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MFC CListCtrl, problem selecting item

Status
Not open for further replies.

KimTherkelsen

Programmer
Jul 27, 2004
1
DK
Hi,
I my program I have a CListCtrl. When the program starts, one of the items in the list control should be selected. It should stay selected until the user selects an other item.
My problem is that I can't get an item to be selected when starting the program. When the user selects an item, the item is only selected until the user clicks elsewhere in the window.

Here is what I do:

CListCtrl round_overview;
round_overview.SubclassDlgItem(IDC_ROUND_LIST,this);

round_overview.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_SHOWSELALWAYS );
round_overview.InsertColumn(0,station, LVCFMT_LEFT,75);
round_overview.InsertColumn(1,round_id, LVCFMT_LEFT,75);
round_overview.InsertColumn(2,emptied_out_of_total, LVCFMT_LEFT,90);

round_overview.InsertItem(round_overview.GetItemCount(),"");

round_overview.SetItemText(round_overview.GetItemCount()-1,0,"test");

round_overview.SetItemState(round_overview.GetItemCount()-1, LVIS_SELECTED | LVIS_FOCUSED , LVIS_SELECTED | LVIS_FOCUSED);


round_overview.EnsureVisible(round_overview.GetItemCount()-1, FALSE);

What have I done wrong?

Best regards
Kim Therkelsen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top