selection issue in listview or TreeView

Posted by Maneesh on Stack Overflow See other posts from Stack Overflow or by Maneesh
Published on 2010-04-21T04:13:12Z Indexed on 2010/04/21 4:23 UTC
Read the original article Hit count: 195

Filed under:

Hello i have a list view control,

While the form is being loaded i fill the list, i have aprrox. say 100+ items. While filling i check some parameters and decide which item/row need to be selected. i set the Selected property to true... refer the code below:

some lines here .....

ListViewItem listViewItem = new ListViewItem("COL1");
listViewItem.SubItems.Add("COL2");

check for some condition and then

listViewItem.Selected = true;
this.m_lstViewCtrl.Items.Add(listViewItem);

This does select the item, there are no issues with it... however, say the ctrl is sized to see onlu say some 15 items, but the selection is say some 35th item.... currently the scroll bar appears the item is selected but i have to scroll to see what was selected?

is it possible to scroll to the selected item so that is selection is clearly visible...

Will the same apply for a Treeview?

© Stack Overflow or respective owner

Related posts about c#