469,627 Members | 1,103 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,627 developers. It's quick & easy.

Listview Selected Item

I'm trying to convert a vb6 program to vb.net (vb2008 express)

I have text data in a Listview Control
I use a Textbox to enter characters to search the Listview
When a Match is found, I use textbox_textchanged to select listview item

Listview1.Items(z).Selected = True
Listview1.Items(z).EnsureVisible ()
Listview1.Items(z).FullRowSelect = True
Listview1.Items(z).ForeColor = Blue

This works fine .

Then when I hit a Aarrow key in the textbox
I set focus to the listview (Listview1.Focus()

Now if I hit a arrow key to scroll the listview, it jumps to the last place
that was Physically selected. or in case of the first hit it starts at the
top of the listview.

In vb6 the same code would start the listview scroll from the selected item.

What am I missing ????
Jan 26 '08 #1
4 13572
On Jan 26, 7:09*pm, "Bill-R" <Bi...@yahoo.comwrote:
I'm trying to convert a vb6 program to vb.net (vb2008 express)

I have text data in a Listview Control
I use a Textbox to enter characters to search the Listview
When a Match is found, I use textbox_textchanged to select listview *item

Listview1.Items(z).Selected = True
Listview1.Items(z).EnsureVisible ()
Listview1.Items(z).FullRowSelect = True
Listview1.Items(z).ForeColor = Blue

This works fine .

Then when I hit a Aarrow key in the textbox
I set focus to the listview (Listview1.Focus()

Now if I hit a arrow key to scroll the listview, it jumps to the last place
that was Physically selected. or in case of the first hit it starts at the
top of the listview.

In vb6 the same code would start the listview scroll from the selected item.

What am I missing ????
If the same code was working with no problem in VB6, i recommend you
to check the listview control's "properties" in properties window.
Compare both platform's listviews to ensure they have the same
properties of VB6's.
Jan 26 '08 #2

"Bill-R" <Bi***@yahoo.comkirjoitti viestissä
news:%2******************@TK2MSFTNGP05.phx.gbl...
I'm trying to convert a vb6 program to vb.net (vb2008 express)

I have text data in a Listview Control
I use a Textbox to enter characters to search the Listview
When a Match is found, I use textbox_textchanged to select listview item

Listview1.Items(z).Selected = True
Listview1.Items(z).EnsureVisible ()
Listview1.Items(z).FullRowSelect = True
Listview1.Items(z).ForeColor = Blue

This works fine .

Then when I hit a Aarrow key in the textbox
I set focus to the listview (Listview1.Focus()

Now if I hit a arrow key to scroll the listview, it jumps to the last
place that was Physically selected. or in case of the first hit it starts
at the top of the listview.

In vb6 the same code would start the listview scroll from the selected
item.

What am I missing ????
When setting focus to Listview1, try this code:

ListView1.Items(z).Focused = True

-Teemu

Jan 26 '08 #3

"Teemu" <ts*****@hotmail.comkirjoitti viestissä
news:Jg********************@reader1.news.saunalaht i.fi...

Or actually my answer was a bit wrong.

When selecting the item:

Listview1.Items(z).Selected = True
Listview1.Items(z).Focused= True
Listview1.Items(z).EnsureVisible ()
Listview1.FullRowSelect = True
Listview1.Items(z).ForeColor = Blue

And then

Listview1.Focus()

to activate the Listview1.

-Teemu

Jan 26 '08 #4
Thanks Teemu !!!!
Was driving me crazy
quite a learning curve for me using .net !
"Teemu" <ts*****@hotmail.comwrote in message
news:_i*********************@reader1.news.saunalah ti.fi...
>
"Teemu" <ts*****@hotmail.comkirjoitti viestissä
news:Jg********************@reader1.news.saunalaht i.fi...

Or actually my answer was a bit wrong.

When selecting the item:

Listview1.Items(z).Selected = True
Listview1.Items(z).Focused= True
Listview1.Items(z).EnsureVisible ()
Listview1.FullRowSelect = True
Listview1.Items(z).ForeColor = Blue

And then

Listview1.Focus()

to activate the Listview1.

-Teemu
Jan 26 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Maheshkumar.R | last post: by
9 posts views Thread by Devron Blatchford | last post: by
1 post views Thread by Shane | last post: by
6 posts views Thread by Brandon McCombs | last post: by
4 posts views Thread by spowel4 | last post: by
12 posts views Thread by Tom Bean | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.