torisch
Newcomer
Hi!
I have a form where I display the contents from a table in a database. For each record in the database i dynamically generate a textbox and a button. The textbox contains the content of the record in the database and my intention is to give the user the possibility to delete the databasereccord by hitting the button.
I put the dynamically generated textboxes and buttons in two arraylists, and adds them to a panel like this.
This is a little simplified, but I manage to generate the form as I want it to look.
My problem is how to respond to a click event from the buttons.
I reccon it has to be dynamically generated events for the buttons too, so that I can find which button the user have clicked.
Anybody has a clue about how I can solve that?
I'm using VB.NET by the way..
--
Tor Inge Schulstad
NORWAY
I have a form where I display the contents from a table in a database. For each record in the database i dynamically generate a textbox and a button. The textbox contains the content of the record in the database and my intention is to give the user the possibility to delete the databasereccord by hitting the button.
I put the dynamically generated textboxes and buttons in two arraylists, and adds them to a panel like this.
Code:
Dim tb as New ArrayList()
Dim btns as New ArrayList()
With rdr
Dim i As Integer = 0
While rdr.Read
'Adding TextBox
tb.Add(New TextBox())
tb(i).text=rdr.item(1).ToString
Me.Panel1.Controls.add(tb(i))
'Adding Button
btns.Add(New Button())
btns(i).text="Delete this record"
Me.Panel1.Controls.add(btns(i))
i = i + 1
End While
.Close()
End With
This is a little simplified, but I manage to generate the form as I want it to look.
My problem is how to respond to a click event from the buttons.
I reccon it has to be dynamically generated events for the buttons too, so that I can find which button the user have clicked.
Anybody has a clue about how I can solve that?
I'm using VB.NET by the way..
--
Tor Inge Schulstad
NORWAY