Solved

ListBox1_SelectedIndexChanged' is not declared.

Posted on 2006-07-14
13
346 Views
Last Modified: 2009-12-16
I am adding a list box to the form like this and i am getting this error.Can you please tell me how to fix it?

       Dim ListBox1 = New ListBox
        ListBox1.Size = New Size(200, 100)   'set size
        ListBox1.Location = New Point(10, 60)  'location
        AddHandler ListBox1.SelectedIndexChanged, AddressOf ListBox1_SelectedIndexChanged   'add the event.
        Me.Controls.Add(ListBox1)
        ListBox1.MultiColumn = True
        ListBox1.SelectionMode = SelectionMode.MultiExtended

 

    for AddressOf ListBox1_SelectedIndexChanged it is giving error
"  Name 'ListBox1_SelectedIndexChanged' is not declared."

0
Comment
Question by:aio419
  • 6
  • 4
13 Comments
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 17109646
Have you created the event handler?
0
 

Author Comment

by:aio419
ID: 17109813
While creating the event hander it is giving error
AddHandler ListBox1.SelectedIndexChanged, AddressOf ListBox1_SelectedIndexChanged  
it  do not like the 2nd part ie.AddressOf ListBox1_SelectedIndexChanged  
Is that what you asked?
0
 
LVL 17

Assisted Solution

by:ZeonFlash
ZeonFlash earned 20 total points
ID: 17109823
As Chaosian said, you're getting that error because you haven't created the event function yet.  Add the following to your code:

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub


You might also need to re-type the listbox (at least I did when trying it out):

        AddHandler CType(ListBox1, ListBox).SelectedIndexChanged, AddressOf ListBox1_SelectedIndexChanged  'add the event.


0
 
LVL 24

Accepted Solution

by:
Jeff Certain earned 20 total points
ID: 17110049
Of course, the easy way to do this is

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

    End Sub
0
 

Author Comment

by:aio419
ID: 17111095
Thanks guys.
Okay. If you want to create a list box at run time, how we do that. Do we have to make the event hander first and then make the list box object? I am not getting that.
I thought I need to create the object and then write the event handler code.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:aio419
ID: 17111105
and how much minimun point is requied to split it?
Thanks
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 17111120
You have to have the event handler written before you add the handler. Second argument to the AddHandler is the name of the subroutine that handles your event

Private Sub CreateControls
       Dim ListBox1 = New ListBox
        ListBox1.Size = New Size(200, 100)   'set size
        ListBox1.Location = New Point(10, 60)  'location
        AddHandler ListBox1.SelectedIndexChanged, AddressOf myHandler
        Me.Controls.Add(ListBox1)
        ListBox1.MultiColumn = True
        ListBox1.SelectionMode = SelectionMode.MultiExtended
End Sub

Private Sub myHandler(ByVal sender As Object, ByVal e As System.EventArgs)
' Do something here
End Sub
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 17111124
I don't htink you can assign less than 20 points per person.
0
 

Author Comment

by:aio419
ID: 17131497
okay i will increase points.
0
 

Author Comment

by:aio419
ID: 17131603
I increasd to 40.Still i do not get split point option!
i can not ignore ZeonFlash' answer either.B'cos he explained  my missing code from Chaosian's answer.

If i am  not getting any other option to split the points , i will award points to Chaosian .
i do not know Chaosian  can do anything to share it.
if that is the case i am very sorry ZeonFlash(even though it is only 20 points)
0
 

Author Comment

by:aio419
ID: 17169015
i do not see the Split Points in that screen.( i had done in the past with 'big' points)
If you(Chaosian) can do it,please do it.Accept your first comment as the answer and ZeonFlash's first comment as the assisted answer.
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

24 Experts available now in Live!

Get 1:1 Help Now