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

Listview Selected Item

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a

"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

P: n/a

"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

P: n/a
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.