By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,566 Members | 1,778 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,566 IT Pros & Developers. It's quick & easy.

auto selecting the 1st item in a list view...

P: n/a
As part of my vb.net 2005 application I would like to automatically select
the very first item (index 0) in a listview containing menu items. That way
the the listviews "afterselect" event would fired - hence running the code
pertaining to that first menu item.

How can I do this in code?

Thanks, Brad
Jul 25 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
ListBox1.SelectedIndex = 0

"Brad Pears" wrote:
As part of my vb.net 2005 application I would like to automatically select
the very first item (index 0) in a listview containing menu items. That way
the the listviews "afterselect" event would fired - hence running the code
pertaining to that first menu item.

How can I do this in code?

Thanks, Brad
Jul 25 '07 #2

P: n/a
I am sorry - I completlely mislead you. It's a treeview NOT a listview.
there is not a "selectedindex" property in a treeview control...

Help!

Brad

"Tracks" <Tr****@discussions.microsoft.comwrote in message
news:E3**********************************@microsof t.com...
ListBox1.SelectedIndex = 0

"Brad Pears" wrote:
>As part of my vb.net 2005 application I would like to automatically
select
the very first item (index 0) in a listview containing menu items. That
way
the the listviews "afterselect" event would fired - hence running the
code
pertaining to that first menu item.

How can I do this in code?

Thanks, Brad

Jul 26 '07 #3

P: n/a
TreeView1.SelectedNode = 0

"Brad Pears" wrote:
I am sorry - I completlely mislead you. It's a treeview NOT a listview.
there is not a "selectedindex" property in a treeview control...

Help!

Brad

"Tracks" <Tr****@discussions.microsoft.comwrote in message
news:E3**********************************@microsof t.com...
ListBox1.SelectedIndex = 0

"Brad Pears" wrote:
As part of my vb.net 2005 application I would like to automatically
select
the very first item (index 0) in a listview containing menu items. That
way
the the listviews "afterselect" event would fired - hence running the
code
pertaining to that first menu item.

How can I do this in code?

Thanks, Brad


Jul 26 '07 #4

P: n/a
Cancel, I mean:

TreeView1.SelectedNode = TreeView1.Nodes(0)

I think? You check it.
"Tracks" wrote:
TreeView1.SelectedNode = 0

"Brad Pears" wrote:
I am sorry - I completlely mislead you. It's a treeview NOT a listview.
there is not a "selectedindex" property in a treeview control...

Help!

Brad

"Tracks" <Tr****@discussions.microsoft.comwrote in message
news:E3**********************************@microsof t.com...
ListBox1.SelectedIndex = 0
>
"Brad Pears" wrote:
>
>As part of my vb.net 2005 application I would like to automatically
>select
>the very first item (index 0) in a listview containing menu items. That
>way
>the the listviews "afterselect" event would fired - hence running the
>code
>pertaining to that first menu item.
>>
>How can I do this in code?
>>
>Thanks, Brad
>>
>>
>>
Jul 26 '07 #5

P: n/a
Perfect!! Yes that works!! Great! Thanks for that!!

"Tracks" <Tr****@discussions.microsoft.comwrote in message
news:CE**********************************@microsof t.com...
Cancel, I mean:

TreeView1.SelectedNode = TreeView1.Nodes(0)

I think? You check it.
"Tracks" wrote:
>TreeView1.SelectedNode = 0

"Brad Pears" wrote:
I am sorry - I completlely mislead you. It's a treeview NOT a listview.
there is not a "selectedindex" property in a treeview control...

Help!

Brad

"Tracks" <Tr****@discussions.microsoft.comwrote in message
news:E3**********************************@microsof t.com...
ListBox1.SelectedIndex = 0

"Brad Pears" wrote:

As part of my vb.net 2005 application I would like to automatically
select
the very first item (index 0) in a listview containing menu items.
That
way
the the listviews "afterselect" event would fired - hence running
the
code
pertaining to that first menu item.

How can I do this in code?

Thanks, Brad


Jul 26 '07 #6

P: n/a
One other quick question.... When the treeview item node is selected
programatically in this fashion, the node does not appear highlited as it
would when you click on it with the mouse. Other than actually setting a
background colour for the node, can you think of an easy way to get this to
happen? I want the user to see which item has been automatically selected...

Thanks, Brad

"Tracks" <Tr****@discussions.microsoft.comwrote in message
news:CE**********************************@microsof t.com...
Cancel, I mean:

TreeView1.SelectedNode = TreeView1.Nodes(0)

I think? You check it.
"Tracks" wrote:
>TreeView1.SelectedNode = 0

"Brad Pears" wrote:
I am sorry - I completlely mislead you. It's a treeview NOT a listview.
there is not a "selectedindex" property in a treeview control...

Help!

Brad

"Tracks" <Tr****@discussions.microsoft.comwrote in message
news:E3**********************************@microsof t.com...
ListBox1.SelectedIndex = 0

"Brad Pears" wrote:

As part of my vb.net 2005 application I would like to automatically
select
the very first item (index 0) in a listview containing menu items.
That
way
the the listviews "afterselect" event would fired - hence running
the
code
pertaining to that first menu item.

How can I do this in code?

Thanks, Brad


Jul 26 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.