473,765 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating Multiple Listviews in Code

Hi,

I have a question regarding the creation of multiple listviews during
run-time. I currently have code that uses a loop to create 5 listviews
with identical properties (excep for the name). Once a listview is
created, it s filled with data loaded from a txt file and then the loop
iterates too creat the next listview.

My problem is that while I am able to create and fill the listviews, I
am not actually able to perform any actions on any of the listviews
except for the one that was created last. By this I mean that if i were
to select an item in a particular listview, only the listview created
last would raise an event (for exmple listview.Select edIndexChanged) .

I know the problem has to do with eveny handling but i'm not sure
exactly what I have to do in order to get each listview to handle
events seperately.

I would appreciate any help on this subject. If it helps I can post my
code...

Thanks,

Waqas

Apr 10 '06 #1
4 1487
Hi you need the addhandler statement, have a look at this example it adds
the click event to all 3 listview

Private Sub form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim myList As ListView
For i As Integer = 0 To 2
myList = New ListView
myList.Name = "list" & CStr(i)
myList.Size = New Size(55, 55)
myList.Location = New Point(60 * (i + 1), 10)
myList.Items.Ad d("Hi I'm number" & CStr(i))
AddHandler myList.Click, AddressOf ListView_Click
Me.Controls.Add (myList)
Next
End Sub

Private Sub ListView_Click( ByVal sender As Object, ByVal e As
System.EventArg s)
MsgBox(DirectCa st(sender, ListView).Name)
End Sub

hope this helps,

Greetz Peter
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Waqas101" <wa********@yah oo.co.uk> schreef in bericht
news:11******** **************@ v46g2000cwv.goo glegroups.com.. .
Hi,

I have a question regarding the creation of multiple listviews during
run-time. I currently have code that uses a loop to create 5 listviews
with identical properties (excep for the name). Once a listview is
created, it s filled with data loaded from a txt file and then the loop
iterates too creat the next listview.

My problem is that while I am able to create and fill the listviews, I
am not actually able to perform any actions on any of the listviews
except for the one that was created last. By this I mean that if i were
to select an item in a particular listview, only the listview created
last would raise an event (for exmple listview.Select edIndexChanged) .

I know the problem has to do with eveny handling but i'm not sure
exactly what I have to do in order to get each listview to handle
events seperately.

I would appreciate any help on this subject. If it helps I can post my
code...

Thanks,

Waqas

Apr 10 '06 #2
Hey thanks a bunch that worked great!

Waqas

Apr 11 '06 #3
Hey thanks a lot that worked great!

Cheers,

Waqas

Apr 11 '06 #4
You're welcome

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Waqas101" <wa********@yah oo.co.uk> schreef in bericht
news:11******** *************@u 72g2000cwu.goog legroups.com...
Hey thanks a lot that worked great!

Cheers,

Waqas

Apr 11 '06 #5

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

Similar topics

21
1568
by: TryingLikeHeck | last post by:
I have an application that uses a LIstView. Maybe 100 items each with 20 subitems. The app looks at eack item and subitem twice. I.e., it scans the entire set of data item1, sub1,sub2,... item2,sub1,sub2... .. .. twice
3
4266
by: simchajoy2000 | last post by:
Hi, I am trying to use a VB.NET listview object to display information from a datatable. I need to have two columns of information but I don't want the user to be able to select each column individually - that's why I am attempting to use a listview rather than a datagrid. I have been reading a lot of postings in this newsgroup concerning multiple columns in listviews and I have tried to follow all the advice I have found - but I am...
3
3881
by: fanny.ricour | last post by:
Hi, I have 2 ListViews, one above the other, and I need to keep them horizontally synchronised. I managed to hide the bottom LV scrollbar (user is not supposed to scroll it) and to scroll it when user clicks on the scollbar or scrollbar arrows. However, the scrollbar does not move when the user keep the scrollbar thingy (I don't know the right word) and move it without releasing the mouse. And unfortunately, that's the easiest way of...
2
2323
by: pagates | last post by:
Hi All, I have an issue where I'd like a single global event to be handled by multiple event handlers. In this case, I would like a "global" (static) Menu Item that I create in a class, and I'd like the controls that use this menu to each react to its Click event. Perhaps I've been spending too much time in the sun? Thanks,
12
3413
by: garyusenet | last post by:
I have had no replies to my previous post so perhaps I didn't write it good enough. Please excuse new thread but i wanted to break from the last thread hopefully this thread will be better. Very simple. I would like to create listviewitem's for display in a listview control. The listview items need to contain properties from Internet Explorer windows i've managed to collect into an arraylist.
1
5432
by: BeckyBair | last post by:
Currently I have a program form that has 2 listviews on it. It is able to copy one item from one listview to another. Now the users want to be able to copy several at once from one listview and paste into the other at point/row where they click/selected. I hope that makes sense. Here is what I have currently for the single copy/paste type of process: Private Sub cmdSetSeqNum_Click() Dim ItmX As ListItem On Error GoTo ERR_HNDL...
1
1496
eyalbi007
by: eyalbi007 | last post by:
Hi all, My main application form occupies two listview controls. Whenever I select a line in one of the listviews, I lose the selection of the selected line in the 2nd listview. The solution of setting the 'HideSelection' property to 'true' is not good enough since I want the selected lines in both listviews to be colored blue, not grey. Any suggestions?
2
6835
by: moondaddy | last post by:
Below is some xaml that is a mockup of a control I'm building. It's a shape that will be used in a diagramming tool. The red, blue and green rectangles simulate connectors on the side of the shape and will have connection lines attached to them. These connectors will be dynamically added and removed at runtime, and at all times, the group of connectors need to be centered on that side. For example, the left side shows a group of 5...
0
1067
by: Carl Malden | last post by:
I need to build a WPF application that will display two listviews. One will be the current Fields list, the other will be the destination. The problem I have is I need to be able to allow users to create, drag, and drop connectors between the listviews to customize the connections between the items in the list. Such as when a user Maps fields for database operations. Can anyone help me with this?
0
10156
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9951
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9832
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7375
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5275
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5419
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.