Groups | Blog | Home
all groups > vb.net controls > december 2005 >

vb.net controls : Two ListView Controls on one form


Terry Olsen
12/1/2005 7:28:32 AM
Have you tried deleting ListView2 and then re-adding it to the form? It's
possible that one of the properties got set wrong, though I have no idea
what it could be. If the Enabled property were set to False, it wouldn't
even catch the mouse-click.

[quoted text, click to view]

Josef Brunner
12/1/2005 2:19:44 PM
Hi,

I have a problem using two ListView controls on one and the same form:

Problem: The second ListView is never focused. No matter where I "click" non
of the items within the ListView is focused.

This is only the matter for the secondly added ListView!!! The first one
works perfectly!!

Example:

' Works perfectly -- Displays a message box with the text of the item where
I clicked
Private Sub ListView1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDown
MsgBox("focussed item :" + ListView1.FocusedItem.Text.ToString)

End Sub



' Crashes saying that ListView2 has no FocusedItem! But I'm sure I
definitely clicked on the item like I do on the first ListView

Private Sub ListView2_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles ListView2.MouseDown

MsgBox("focussed item :" + ListView2.FocusedItem.Text.ToString)

End Sub



Any ideas would be very appreciated,

Joe

Josef Brunner
12/1/2005 3:54:51 PM
Hi again,

thank for your fast reply :)

I already tried creating a new project, adding two ListView controls (no
changes to any properties, Enabled is default), adding a column and a single
item to each ListView.

Then I define the event "Mouse_Down" where I set a break point to check
whether the controls/items are focused.

It works perfectly for the first ListView but not for the second one?!
Strange isn't it?!

Thanks again,
Joe

"Terry Olsen" <tolsen64@hotmail.com> schrieb im Newsbeitrag
news:%23%23eZBOo9FHA.476@TK2MSFTNGP15.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button