473,324 Members | 2,511 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 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 6102
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mr. B | last post by:
VB.net issue here. I've a strange event that I can't seem to figure out... On my Form, I've a TabControl (two Tabs)... On my first tab, I load an Ascii file and dump some info onto my...
2
by: Kanaiya | last post by:
hello how to put images in either listbox or listview.bye. -- With regards, Gangani Kanaiya.
4
by: Paddy | last post by:
How do I select a subitem from a listview after clicking on the first column? Couldn't find it in MSDN. Thank you. Paddy.
0
by: Ben Rush | last post by:
Greetings, I don't deal too much with the visual side of the framework, so I may be simply doing something quite stupid - but if I am I can't figure it out for the life of me. On my machine...
2
by: farmer | last post by:
I need to populate a listbox of other listview with selected listview items.although the following code works perfecty I want to use an Array (for various reasons) for Each ListItem In...
4
by: CR | last post by:
In VB6 if I wanted to display a group of records, and possibly allow the user to select one or more records, I would use the ListBox. For example suppose I wanted to display something like this: ...
1
by: Melson | last post by:
Hi May I know what is the differences between vb.net listbox and listview. When should I use listbox or listview. Regards Melson
1
by: The Confessor | last post by:
I currently have a listbox in my program which I populate with data from a random access file as follows: For T = 1 To HighestPointID FileGet(1, Point(T), T) ListBox_Point.Items.Add(T & " Lat:...
6
by: Brandon McCombs | last post by:
Hello, I have a form that contains a listview on the left side and a column of buttons on the right side. Only some of the buttons do I want enabled all the time. The other buttons should be...
2
by: markliam | last post by:
I have a ListBox that is displaying a formatted string based on the contents of a DataSet. The purpose of the listbox is for the user to select an entry to delete, but I'm not sure how to match...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.