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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List control problem 1

Status
Not open for further replies.

timmay3141

Programmer
Dec 3, 2002
468
0
0
US
I'm having a wierd problem with a list control. I checked the "Show selection always" checkbox, but it still doesn't always show the selection when I am using other controls. As far as I can tell, the checkbox does nothing at all. Is there some way to make this work correctly?
 
Look out MSDN for CListCtrl::EnsureVisible().
I think this should serve ur purpose?

Hope this helps

mathu
 
No, that's not it. I want the selected row to be highlighted even when I am changing other controls. What EnsureVisible does is scroll a list control to make an item visible.
 
>> "Show selection always" checkbox

Works for me. What else can you tell us?

-pete
 
This is happening on a property page. The user selects an item on the list control, and other controls on the page fill with attributes associated with the selected item. They can then press a button on the property page to confirm their changes and update the list control to reflect it. It looks something like this:

void CPropertyPage::OnApplyChanges()
{
// Make changes

int nSel = m_lcReagents.GetSelectionMark();
PopulateListControl(); // Refreshes list control data
m_lcReagents.SetSelectionMark(nSel);
}

I called GetSelectionMark() after setting the selection mark (to make sure it was working properly), and the index of the item I wanted selected was returned, so it should be working right. However, none of the items in the list control were highlighted, and I'm trying to figure out why.
 
Hey timmay, ask the actual question in your first post and save everyone a lot of time.
Code:
m_lcReagents.SetItemState(nSel,LVIS_SELECTED,LVIS_SELECTED);

-pete
 
What do you mean? I did ask my question the first time. I said:

>I checked the "Show selection always" checkbox, but it still doesn't always show the selection

This was true. It seems to me that SetSelectionMark should actually select the item you tell it to, so I didn't see a need to mention it at first - I assumed it was something else that was not working. It was a bad assumption, but you don't need to get mad about it.

Also, what you suggested worked. Thanks.
 
>> but you don't need to get mad about it.

Who's mad [lol] That was a tip... not a debasing comment. Heck I didn’t even give you hammer...
[hammer]

>> It was a bad assumption

Most assumptions in software development are bad ones.

[machinegun] ….(assumption)


-pete
 
>Who's mad

You are, obvisously. Someone with an answer to literally all questions here can't be all that sane.

>Most assumptions in software development are bad ones.

"Assumption is the mother of all f*ck-ups"



/Per
[sub]Nerdy signatures are as lame as the inconsistent stardates of STTNG.[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top