Solved

listview control

Posted on 2004-10-20
6
945 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

772 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