Hi guys,

I am creating several link labels at runtime. I am using the following code:
VB Code:
  1. 'Get all questions with matching qID and create linklabels for each.
  2.         For j As Integer = 0 To PhotoPicker.arrQuestion.Length - 2
  3.             If PhotoPicker.arrQuestion(j).qID = questionnaireID Then
  4.                 lnk_Question = New LinkLabel
  5.                 With lnk_Question
  6.                     .Text = PhotoPicker.arrQuestion(j).question.ToString
  7.                     .Top = PhotoPicker.pnl_Questions.Top + (count * 35)
  8.                     .Width = PhotoPicker.pnl_Questions.Width - 25
  9.                     .Height = 30
  10.                     .Left = PhotoPicker.pnl_Questions.Left + 10
  11.                     .Parent = PhotoPicker.pnl_Questions
  12.                     AddHandler lnk_Question.Click, AddressOf lnk_Question_click
  13.                 End With
  14.                 PhotoPicker.pnl_Questions.Controls.Add(lnk_Question)
  15.                 count += 1
  16.             End If
  17.         Next

Now the link labels display fine but when i click on a link label i need to compare the text of the link label to an array and return the element number. Now when i actually click on any link label it returns the text of the last link label created.
Can anybody tell me why it is doing this and how i can get around it?

Thanks in advance for any help


(I am using .net compact framework -> but i dont think that will make a difference to how to tackle this problem.)