Solved

listview control

Posted on 2004-10-20
6
943 Views
Last Modified: 2010-04-24
hey all...
i just got visual studio .net enterprise architect edition so im a newbie to it (i have previously used vb6)

i no this may seem like a really silly question but here goes...

how do i do an event when a certain item in a listview control is selected

i know in vb6 i used to use something like this
            If Item.Index = 1 Then Frame1.Visible = True

i just cant seem to get my head around all these new things


thanks in advance --Laser--
0
Comment
Question by:--laser--
  • 3
  • 2
6 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 12358483
the ListBox control in .NET has a SelectedIndex property, which is EXACTLY equivalent to the Item.Index property that you are familiar with from VB 6:

If MyList.SelectedIndex = 1 then Frame1.Visiable = True

However, with .NET items added to a ListBox can be complete Objects, not just strings, so you can also return the SelectedItem (the object that was selected).  the .NET Listbox also allows Multiple selections, so you can have a SelectedIndeces collection, and a SelectedItems collection as well.  This is very powerful stuff, compared to the limited capabilities that were available with vb 6, and it takes a bit to get your head around the power.

AW
0
 
LVL 4

Author Comment

by:--laser--
ID: 12363894
yeh i agree that vb .NET is a lot more powerful but i still cant seem to get this to work...

If ListView1.selectedindex = 1 Then MsgBox("hi")

listview1.selectedindex is underlined blue and the tooltip thing says 'selectedindex' is not a member of 'system.windows.forms.listview'
0
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 50 total points
ID: 12366884
ListView has a selected Items Collection and SelectedIndices collection

your above code will get modifed to

If ListView1.SelectedIndices.Contains(1) Then MsgBox("hi")



0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 4

Author Comment

by:--laser--
ID: 12366904
thank you both very much thats exactly what im looking for arif egbal
0
 
LVL 4

Author Comment

by:--laser--
ID: 12367321
just one more thing if you dont mind

this is probably just as easy if not easier...

how do i access a control on a form through a module

like in vb6 it was form1.winsocksend.senddata data
for example

how do i do this in vb.net
0
 
LVL 19

Expert Comment

by:arif_eqbal
ID: 12367783
See that's not quite the way with Object Oriented programming
You see a Module is now like a global class its public functions are accessible to all but the vice versa is not true. It can only access the Forms/Controls which are made available to it.

You can always have a module level variable that holds a reference to a form but that's not advisable as it is against Encapsulation.

In order to do what you want you should Pass the winsocksend Object as an Argument to the function in the module which will call its method SendData

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now