473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Two ListView Controls on one form

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
Dec 1 '05 #1
6 1916
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.

"Josef Brunner" <jo**@newsgroups.nospam> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
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

Dec 1 '05 #2
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" <to******@hotmail.com> schrieb im Newsbeitrag
news:%2*****************@TK2MSFTNGP15.phx.gbl...
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.

"Josef Brunner" <jo**@newsgroups.nospam> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
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


Dec 1 '05 #3
Hi Jeffrey,

thanx for your help. What I did:

- I compiled and started your sample program
- I click on the item on the first (upper) ListView control -- displays the
message box correctly
- After that I click on the item on the second (lower) ListView control --
displays the error message that there is no focuseditem for this ListView

Maybe my OS or dot.net framework somehow got messed up??

I really have no clue what to do on this. Sure I can come around on that
problem by inserting this on the mouse_down event:
Dim myItem As ListViewItem = ListView2.GetItemAt(e.X, e.Y)
myItem.Focused = True

But this doesn't work for other events I use, like Double_Click since there
the "e" object has no X and Y coordinates to get the focuseditem

Really appreciate your help,
Kurt
""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> schrieb im Newsbeitrag
news:xf**************@TK2MSFTNGXA02.phx.gbl...
Hi Josef,

Thanks for your post.

First, because you are adding column, so I assumed that you use Details
mode for ListViews.

Currently, I have created a sample for you. However, it works well on my
side.

I have attached my sample project in this reply. You can get it with
Outlook Express(can not get with IE)

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Dec 2 '05 #4
Hi Kurt,

Thanks for your feedback.

Currently, I do not have much idea about the root cause, it seems it is
caused by the OS and .Net Framework.

Can we try re-install the OS or the .Net Framework? I think this may
resolve this problem.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Dec 5 '05 #5
Hi Jeffrey,

thanks for staying with me in this problem :)

I just installed the new Visual Studio 2005 (with the latest 2.0 framework)
and it still won't work. Maybe you're right, maybe it is the OS, but
reinstalling it will be difficult. I will test it on another machine...

thx-a-lot
Kurt
""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> schrieb im Newsbeitrag
news:Br****************@TK2MSFTNGXA02.phx.gbl...
Hi Kurt,

Thanks for your feedback.

Currently, I do not have much idea about the root cause, it seems it is
caused by the OS and .Net Framework.

Can we try re-install the OS or the .Net Framework? I think this may
resolve this problem.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Dec 6 '05 #6
Hi Josef,

Yes, I also recommanded first testing on another machine before
re-installing OS. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Dec 7 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Welie | last post by:
Hi all- I am using a listview (MSComctlLib.ListViewCtrl.2)on an Access form. Actually there are six listviews on the form. I need to do the same thing to all six forms so I have the loop below....
6
by: Vanessa | last post by:
With this program I can do one selection, but upon the second I get an error where ///////////////// is indicated. Please help. using System; using System.Drawing; using System.Collections;...
4
by: Paddy | last post by:
How do I select a subitem from a listview after clicking on the first column? Couldn't find it in MSDN. Thank you. Paddy.
0
by: Andrew | last post by:
If item is a ListViewItem and str is a string, why do the following two lines not have the same effect ? item.SubItems.Add(new ListViewItem.ListViewSubItem()).Text = str;...
0
by: PeacError | last post by:
Using Microsoft Visual Studio .NET 2003, Visual C# .NET 1.1: I apologize if this question has been addressed elsewhere, but I could not find a reference to it in the search engine for this...
21
by: StriderBob | last post by:
Situation : FormX is mdi child form containing 2 ListViews ListView1 contains a list of table names and 4 sub items with data about each table. ListView2 contains a list of the columns on each...
4
by: firefox | last post by:
Hola Foro!, tengo una rutina que permite agregar varios elementos o items de una sola vez en un ListView. Lo que sucede es que en el momento que se añaden los items al ListView se pone todo blanco,...
9
by: Kadett | last post by:
Hi all, I have following problem: I'm creating a ListView (Details) control at run-time and filling it with some records (let's say 10 000). This operation seems to be quite fast, but when I call...
10
by: Rob | last post by:
VS 2005 How can you tell if a value is contained in a specific column (let's say column 1 named Status) of a ListView ? In a list box you could go... If ListBox1.Items.Contains(strWhatever)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.