473,587 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Mouse Down(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles ListView1.Mouse Down
MsgBox("focusse d item :" + ListView1.Focus edItem.Text.ToS tring)

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_Mouse Down(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles ListView2.Mouse Down

MsgBox("focusse d item :" + ListView2.Focus edItem.Text.ToS tring)

End Sub

Any ideas would be very appreciated,

Joe
Dec 1 '05 #1
6 1930
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**@newsgroup s.nospam> wrote in message
news:et******** ******@TK2MSFTN GP09.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_Mouse Down(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles ListView1.Mouse Down
MsgBox("focusse d item :" + ListView1.Focus edItem.Text.ToS tring)

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_Mouse Down(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles ListView2.Mouse Down

MsgBox("focusse d item :" + ListView2.Focus edItem.Text.ToS tring)

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******@hotma il.com> schrieb im Newsbeitrag
news:%2******** *********@TK2MS FTNGP15.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**@newsgroup s.nospam> wrote in message
news:et******** ******@TK2MSFTN GP09.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_Mouse Down(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles ListView1.Mouse Down
MsgBox("focusse d item :" + ListView1.Focus edItem.Text.ToS tring)

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_Mouse Down(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles ListView2.Mouse Down

MsgBox("focusse d item :" + ListView2.Focus edItem.Text.ToS tring)

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.GetIt emAt(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.mi crosoft.com> schrieb im Newsbeitrag
news:xf******** ******@TK2MSFTN GXA02.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.mi crosoft.com> schrieb im Newsbeitrag
news:Br******** ********@TK2MSF TNGXA02.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
5950
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. I would like to assign each control to a listview object, however I get a type mismatch. Further investigation reveals that the type of the control...
6
2524
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; using System.ComponentModel; using System.Windows.Forms; using System.Data;
4
9701
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
12274
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; item.SubItems.Add(str); In the example code that follows, using the first line (in the ListView constructor) causes the later redisplay of values (to some specified...
0
5407
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 board. I have a form that contains a ListView and a GroupBox control. The GroupBox control itself contains several TextBox Controls. I have...
21
5189
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 table and 11 sub items with data about each column. When a Row in ListView1 is selected the Data in ListVies2 is loaded to show the correct data....
4
3854
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, cuando se terminan de agregar los items vuelve a su estado normal. Como impido que esto suceda ?. Gracias Mil.
9
4471
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 Controls.Add(list), where list is my ListView control, then program hangs for minute. It seems like this time depends on number of records added to...
10
4031
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) then How would you accomplish this using a ListView ?
0
7915
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8205
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8339
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5712
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.