I'm having a lot of trouble programatically selecting a listview item. How
do you do this?
These didn't work for me in the context of the sub below (that's trying to
move up an Item in the listview)
MeasView.Items(ItemIndex - 1).Selected = True
MeasView.Items(ItemIndex - 1).Focused = True
I would really appreciate some help.
thank you,
Rich
Private Sub MoveUpButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MoveUpButton.Click
Dim ItemIndex As Integer
Select Case MeasView.SelectedIndices.Count
Case 0
MessageBox.Show("You must select a measure to move first")
Case Is > 1
MessageBox.Show("You must select just one measure to move")
Case 1
'Find the item and check it's index
ItemIndex = MeasView.SelectedIndices.Item(0)
If ItemIndex = 0 Then
MessageBox.Show("You can't move this item up any more")
Else
MeasView.Items(ItemIndex).Text = (ItemIndex -
1).ToString.PadLeft(2, "0")
MeasView.Items(ItemIndex - 1).Text =
(ItemIndex).ToString.PadLeft(2, "0")
MeasView.Sorting = SortOrder.None
MeasView.Sorting = SortOrder.Ascending
MeasView.Items(ItemIndex - 1).Selected = True
MeasView.Items(ItemIndex - 1).Focused = True
End If
End Select
End Sub 5 37253
do this before trying to select the lines
MeasView.Focus()
"Richard Bond" <Ri**********@tnsofres.com> wrote in message
news:uD**************@TK2MSFTNGP11.phx.gbl... I'm having a lot of trouble programatically selecting a listview item. How do you do this?
These didn't work for me in the context of the sub below (that's trying to move up an Item in the listview)
MeasView.Items(ItemIndex - 1).Selected = True MeasView.Items(ItemIndex - 1).Focused = True
I would really appreciate some help.
thank you,
Rich
Private Sub MoveUpButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MoveUpButton.Click Dim ItemIndex As Integer
Select Case MeasView.SelectedIndices.Count Case 0 MessageBox.Show("You must select a measure to move first") Case Is > 1 MessageBox.Show("You must select just one measure to
move") Case 1 'Find the item and check it's index ItemIndex = MeasView.SelectedIndices.Item(0) If ItemIndex = 0 Then MessageBox.Show("You can't move this item up any
more") Else MeasView.Items(ItemIndex).Text = (ItemIndex - 1).ToString.PadLeft(2, "0") MeasView.Items(ItemIndex - 1).Text = (ItemIndex).ToString.PadLeft(2, "0") MeasView.Sorting = SortOrder.None MeasView.Sorting = SortOrder.Ascending MeasView.Items(ItemIndex - 1).Selected = True MeasView.Items(ItemIndex - 1).Focused = True End If End Select
End Sub
Hello,
"Richard Bond" <Ri**********@tnsofres.com> schrieb: I'm having a lot of trouble programatically selecting a listview item. How do you do this?
These didn't work for me in the context of the sub below (that's trying to move up an Item in the listview)
Set the ListView's 'HideSelection' property to False.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET http://www.mvps.org/dotnet
Thanks very much - That's done the trick - why did it not have focus in the
first place though?
"One Handed Man [ OHM ]" <te***************************@BTOpenworld.com>
wrote in message news:uq**************@TK2MSFTNGP10.phx.gbl... do this before trying to select the lines
MeasView.Focus()
"Richard Bond" <Ri**********@tnsofres.com> wrote in message news:uD**************@TK2MSFTNGP11.phx.gbl... I'm having a lot of trouble programatically selecting a listview item.
How do you do this?
These didn't work for me in the context of the sub below (that's trying
to move up an Item in the listview)
MeasView.Items(ItemIndex - 1).Selected = True MeasView.Items(ItemIndex - 1).Focused = True
I would really appreciate some help.
thank you,
Rich
Private Sub MoveUpButton_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MoveUpButton.Click Dim ItemIndex As Integer
Select Case MeasView.SelectedIndices.Count Case 0 MessageBox.Show("You must select a measure to move
first") Case Is > 1 MessageBox.Show("You must select just one measure to move") Case 1 'Find the item and check it's index ItemIndex = MeasView.SelectedIndices.Item(0) If ItemIndex = 0 Then MessageBox.Show("You can't move this item up any more") Else MeasView.Items(ItemIndex).Text = (ItemIndex - 1).ToString.PadLeft(2, "0") MeasView.Items(ItemIndex - 1).Text = (ItemIndex).ToString.PadLeft(2, "0") MeasView.Sorting = SortOrder.None MeasView.Sorting = SortOrder.Ascending MeasView.Items(ItemIndex - 1).Selected = True MeasView.Items(ItemIndex - 1).Focused = True End If End Select
End Sub
Because when you clicked the button, the button received focus and the
listview was Blurred
Regards - OHM
"Richard Bond" <Ri**********@tnsofres.com> wrote in message
news:ek**************@tk2msftngp13.phx.gbl... Thanks very much - That's done the trick - why did it not have focus in
the first place though?
"One Handed Man [ OHM ]" <te***************************@BTOpenworld.com> wrote in message news:uq**************@TK2MSFTNGP10.phx.gbl... do this before trying to select the lines
MeasView.Focus()
"Richard Bond" <Ri**********@tnsofres.com> wrote in message news:uD**************@TK2MSFTNGP11.phx.gbl... I'm having a lot of trouble programatically selecting a listview item. How do you do this?
These didn't work for me in the context of the sub below (that's
trying to move up an Item in the listview)
MeasView.Items(ItemIndex - 1).Selected = True MeasView.Items(ItemIndex - 1).Focused = True
I would really appreciate some help.
thank you,
Rich
Private Sub MoveUpButton_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MoveUpButton.Click Dim ItemIndex As Integer
Select Case MeasView.SelectedIndices.Count Case 0 MessageBox.Show("You must select a measure to move first") Case Is > 1 MessageBox.Show("You must select just one measure to move") Case 1 'Find the item and check it's index ItemIndex = MeasView.SelectedIndices.Item(0) If ItemIndex = 0 Then MessageBox.Show("You can't move this item up any more") Else MeasView.Items(ItemIndex).Text = (ItemIndex - 1).ToString.PadLeft(2, "0") MeasView.Items(ItemIndex - 1).Text = (ItemIndex).ToString.PadLeft(2, "0") MeasView.Sorting = SortOrder.None MeasView.Sorting = SortOrder.Ascending MeasView.Items(ItemIndex - 1).Selected = True MeasView.Items(ItemIndex - 1).Focused = True End If End Select
End Sub
Hey that works aswell.The only difference being that the selection colour
changes from blue to grey
(no problem for me but my boss will tell me it will confuse the users)
thanks very much,
Rich
"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:#L**************@TK2MSFTNGP11.phx.gbl... Hello,
"Richard Bond" <Ri**********@tnsofres.com> schrieb: I'm having a lot of trouble programatically selecting a listview item. How do you do this?
These didn't work for me in the context of the sub below (that's trying to move up an Item in the listview)
Set the ListView's 'HideSelection' property to False.
-- Herfried K. Wagner MVP · VB Classic, VB.NET http://www.mvps.org/dotnet
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dave Wijay |
last post by:
Hi
Does anybody know how to programmatically select items (rows) of a ListView in C#.NET
Thanks in advanc
Dave
|
by: Richard |
last post by:
>-----Original Message-----
> before the listview is displayed
The BEFORE DISPLAYED might be your problem. As a guess
I'd try moving the code to the
form's "OnVisibilityChanged" handler:
if...
|
by: Shane |
last post by:
I have a text box select items in a listview as text is being typed
into the text box. I get the select bar to move correctly in the
Listview control.
If the user presses the down or up key in...
|
by: Joerg Trumpfheller |
last post by:
Hey folks,
I have a problem with selecting an item in a listview control from outside.
Listview items are binded with unique ids.
I got now an id from another control and want to select the...
|
by: rlg |
last post by:
We have C# 2005 multi-threaded app.
A background thread is processing data and periodically updating the
contents of a ListView. Sometimes, the user clicking on a ListView
item will not select...
| |
by: Phill W. |
last post by:
(VB'2003)
What's the correct way to remove multiple, selected items from a
ListView control (say, from a ContextMenu)?
I ask because I'm getting a very annoying ArgumentOutOfRangeException...
|
by: =?Utf-8?B?Q2FibGVHdXk=?= |
last post by:
If I have an unsorted listview I know I can select the first Item by
ListView.Items.Selected = true. How do I select the first item in a sorted
listview?
Thanks.
CableGuy
|
by: polocar |
last post by:
Hi,
I'm using Visual C# 2005 (part of Visual Studio 2005 Professional
Edition), and I have the following problem:
I populate a ListView object with several items, and at the end of
this process I...
|
by: Tom |
last post by:
How can I programmatically activate an item in a ListView?
I'm using a detail view with double click to activate using the mouse.
When I change the font size that forces a refresh of the list ......
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |