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!

How to select the first item in a selected row using the list control 1

Status
Not open for further replies.

chriscorran

Programmer
Oct 20, 2002
15
0
0
GB
Hello !!!!!!!!!

I need to be able to pull out the first column value for a specific row using the list control. I can do it but only if I click the actual first column. Is it possible to choose the first column value even if I click the second or third column. It's really easy in VB but I just can't do it in VC++. It must be possible.

Just for explanations sake the list control is made up three columns

ID firstName secondName

3 Billy conway
4 fred flintstone
7 Jenny James
9 Phill Peters

Heres what I got to pull out the first column value, but it only works if I click the first column.

int item = m_lv_control.GetNextItem(-1, LVNI_SELECTED);

varValue = m_lv_control.GetItemText(item,0);

Please help !!!

Thanks in advance.
 
Yes, you need to call [tt]SetExtendedStyle()[/tt] on your list box with the style [tt]LVS_EX_FULLROWSELECT[/tt] - this way the whole row is selected no matter where you click.
tellis.gif

[sup]programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.[/sup]​
 
Cheers fella. You put me on the right track.

In OnInitDialog()

m_lv_control.SendMessage( LVM_SETEXTENDEDLISTVIEWSTYLE, 0,LVS_EX_FULLROWSELECT );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top