![]() |
|
#1
|
|||
|
|||
MFC CListCtrl, problem selecting itemHi,
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 only is 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_FULLROWSELE CT | 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.GetItemCo unt(),""); round_overview.SetItemText(round_overview.GetItemC ount()-1,0,"test"); round_overview.SetItemState(round_overview.GetItem Count()-1, LVIS_SELECTED | LVIS_FOCUSED , LVIS_SELECTED | LVIS_FOCUSED); round_overview.EnsureVisible(round_overview.GetIte mCount()-1, FALSE); What have I done wrong? Best regards Kim Therkelsen |
|
#2
|
|||
|
|||
|
round_overview.SetCurSel(x); ???
where x is the zero based index number. At least that works in my app (using the mfc app wizard(exe)) |
|
#3
|
|||
|
|||
|
Thank you for your answer,
but I can't get that to work because setCurSel() is not a member of the CListCtrl class. |
|
#4
|
|||
|
|||
|
try the onther from GetCheck (get selected item), the "SetCheck()", wich is a member of CListCtrl
BOOL SetCheck( int nItem, BOOL fCheck = TRUE ): Parameters nItem The zero-based index of a list control item. fCheck Specifies whether the state image of the item should be visible or not. By default, fCheck is TRUE and the state image is visible. If fCheck is FALSE, it is not visible. More info on msdn.microsoft.com about SetCheck and the other functions of clistctrl |
|
#5
|
|||
|
|||
|
sorry about that, works for me though honest....
get the impression you're doing this the detailed way, which i'm sure is better, but I'm a sucker for the easy option and just created a list box with MSVC++ mfc exe wizard and added a control to it via class wizard. Doing it this way does give you SetCurSel() as a member function. I'm yet to venture out on my own without the good old wizards though....all this win32 stuff looks seriously long winded. |
|
#6
|
|||
|
|||
|
Whats Up.
I had that problem too. Try round_overview.SetFocus() too keep the focus on the list. Bye... |
Recent GIDBlog
Writing a book by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| CD burner wont burn!! | robertli55 | Computer Hardware Forum | 1 | 18-Jun-2004 11:53 |
| Yet another CD burner problem: Lite-On LSC-24082K | Erwin | Computer Hardware Forum | 1 | 22-May-2004 12:28 |
| help on linked lists any1????? | nick4 | C Programming Language | 1 | 17-May-2004 10:32 |
| Another FX 5600 problem (but with details that might shed light on this) | BobDaDuck | Computer Hardware Forum | 2 | 16-Apr-2004 08:53 |
| problem with creating class | mohammed | C++ Forum | 1 | 11-Oct-2003 10:04 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The