Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I've got a ListBox that has its Items automatically generated. It basically adds all the items in a directory:

 

for (int i=0; i<sArray.Count; i++)
{
this.LocalList.Items.Add(sArray[i].ToString());
}

 

How can I squeeze an EventHandler in there to each added item?

Edited by solus
Can't afford to be neutral on a moving train...
Posted
Could you give me an example of these handlers? Or a reference to a page that gives an example?
Can't afford to be neutral on a moving train...
  • *Experts*
Posted

In the IDE code window use the top-left combo to select the ListBox

control, and the right combo to select the event. You can choose

the SelectIndexChanged event, for example, to find which item was

clicked:

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
   MessageBox.Show("You chose item #" & ListBox1.SelectedIndex + 1)
End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...