471,325 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

listview vs listbox?


In ListBox, I can use SelectedIndex to set for current selected item.
for(int x = 0; x <25; x++)
listBox1.Items.Add(x.ToString());

listBox1.SelectedIndex = 10;

How to do the same for ListView?

Feb 20 '06 #1
3 6037
See there: http://www.syncfusion.com/FAQ/Window...90c.aspx#q797q

"ttan" wrote:

In ListBox, I can use SelectedIndex to set for current selected item.
for(int x = 0; x <25; x++)
listBox1.Items.Add(x.ToString());

listBox1.SelectedIndex = 10;

How to do the same for ListView?


--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche

Feb 20 '06 #2
Hi,
"ttan" <tt**@discussions.microsoft.com> wrote in message
news:B0**********************************@microsof t.com...

In ListBox, I can use SelectedIndex to set for current selected item.
for(int x = 0; x <25; x++)
listBox1.Items.Add(x.ToString());

listBox1.SelectedIndex = 10;

How to do the same for ListView?


You use ListViewItemItem.Selected , so the code should be:

listview1.Items[ 10].Selected = true;
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Feb 20 '06 #3

When I use the code you provided, but how come the scroll bar of listview is
not at the position of the selected item. Inlist box when I do selectedIndex
the scroll bar is at the selected position.

Did I missing something?

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,
"ttan" <tt**@discussions.microsoft.com> wrote in message
news:B0**********************************@microsof t.com...

In ListBox, I can use SelectedIndex to set for current selected item.
for(int x = 0; x <25; x++)
listBox1.Items.Add(x.ToString());

listBox1.SelectedIndex = 10;

How to do the same for ListView?


You use ListViewItemItem.Selected , so the code should be:

listview1.Items[ 10].Selected = true;
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Feb 24 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Mr. B | last post: by
4 posts views Thread by Paddy | last post: by
reply views Thread by Ben Rush | last post: by
2 posts views Thread by farmer | last post: by
4 posts views Thread by CR | last post: by
1 post views Thread by The Confessor | last post: by
6 posts views Thread by Brandon McCombs | last post: by
2 posts views Thread by markliam | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.