|
-
Oct 22nd, 2006, 10:25 AM
#1
Thread Starter
Junior Member
[RESOLVED] Setting Focus on the last item in the listview
Hi
How can I set the focus on the last item in the listview control?
item.selected=true doesnt set it focused.
-
Oct 22nd, 2006, 11:58 AM
#2
Re: Setting Focus on the last item in the listview
listview1.listitems(listview1.listitems.count).selected = true
-
Oct 22nd, 2006, 12:06 PM
#3
Thread Starter
Junior Member
Re: Setting Focus on the last item in the listview
 Originally Posted by leinad31
listview1.listitems(listview1.listitems.count).selected = true
not working... while the listview is being populated.
-
Oct 22nd, 2006, 12:08 PM
#4
Re: Setting Focus on the last item in the listview
does the listview have the focus? If you want the selected item to be highlighted even when listview loses focus.
ListView1.HideSelection = False
If your listview is set to muliselection then you'll have to use EnsureVisible
And if its while being populated, then set the listitem's Selected property and call ensurevisible just after being added.
Use this syntax so you have a reference, in this case lstNew holds the reference to the just added listitem
VB Code:
Dim lstNew As ListItem
Set lstNew = ListView1.ListItems.Add
lstNew.Text = "Test"
lstNew.Selected = True
lstNew.EnsureVisible
Last edited by leinad31; Oct 22nd, 2006 at 12:12 PM.
-
Oct 22nd, 2006, 12:13 PM
#5
Thread Starter
Junior Member
Re: Setting Focus on the last item in the listview
 Originally Posted by leinad31
does the listview have the focus? If you want the selected item to be highlighted even when listview loses focus.
ListView1.HideSelection = False
If your listview is set to muliselection then you'll have to use EnsureVisible
And if its while being populated, then set the listitem's Selected property and call ensurevisible just after being added.
Use this syntax so you have a reference, in this case lstNew holds the reference to the just added listitem
VB Code:
Dim lstNew As ListItem
Set lstNew = ListView1.ListItems.Add
lstNew.Text = "Test"
lstNew.Selected = True
lstNew.EnsureVisible
WORKING................... PROBLEM SOLVED!
Last edited by sufyaaan; Oct 22nd, 2006 at 12:18 PM.
-
Oct 22nd, 2006, 12:16 PM
#6
Re: Setting Focus on the last item in the listview
eh? check everything... are you sure the listview is enabled? are you sure it can receive focus (on the active form), or you can select items with clicks? are you sure you don't have code elsewhere that's setting selected = false and setting listview1.selecteditem = nothing?
and post the code for populating it.
-
Oct 22nd, 2006, 12:19 PM
#7
Thread Starter
Junior Member
Re: Setting Focus on the last item in the listview
 Originally Posted by leinad31
eh? check everything... are you sure the listview is enabled? are you sure it can receive focus (on the active form), or you can select items with clicks? are you sure you don't have code elsewhere that's setting selected = false and setting listview1.selecteditem = nothing?
and post the code for populating it.
ITS WORKING! THANKS! YOU ROCK! (y)
-
Oct 22nd, 2006, 12:37 PM
#8
Re: Setting Focus on the last item in the listview
Ok. Pls take the time to mark the thread as resolved
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|