KimTherkelsen
Programmer
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
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