mariuslaurentiu
Programmer
I am writing an application that requires button controls to be created at runtime because the amoutn of controls created depends on data retrieved from a database.
Do While (SQLreader.Read())
EtichetaControl = SQLreader4("EtichetaControl").ToString()
TipControl = SQLreader4("TipControl").ToString()
ColtStanga = SQLreader4("ColtStanga").ToString()
ColtSus = SQLreader4("ColtSus").ToString()
InaltimeForma = SQLreader4("InaltimeForma").ToString()
LatimeForma = SQLreader4("LatimeForma").ToString()
ColtStangaForma = SQLreader4("ColtStangaForma").ToString()
ColtSusForma = SQLreader4("ColtSusForma").ToString()
LungimeControl = SQLreader4("LungimeControl").ToString()
ProceduraApelata = SQLreader4("ProceduraApelata").ToString()
ControlId = SQLreader4("ControlId").ToString()
Dim TempButton As New Button()
TempButton.Name = "TempButton" & CStr(ControlId)
TempButton.Text = EtichetaControl
TempButton.Top = ColtSus
TempButton.Left = ColtStanga
TempButton.Width = LungimeControl
AddHandler TempButton.Click, AddressOf Executie
Loop
Private Sub Executie(ByVal sender As System.Object, ByVal e As System.EventArgs)
If TypeOf sender Is Button Then
' when i press the button i wish to execute stored procedure ProceduraApelata
End If
End Sub
Do While (SQLreader.Read())
EtichetaControl = SQLreader4("EtichetaControl").ToString()
TipControl = SQLreader4("TipControl").ToString()
ColtStanga = SQLreader4("ColtStanga").ToString()
ColtSus = SQLreader4("ColtSus").ToString()
InaltimeForma = SQLreader4("InaltimeForma").ToString()
LatimeForma = SQLreader4("LatimeForma").ToString()
ColtStangaForma = SQLreader4("ColtStangaForma").ToString()
ColtSusForma = SQLreader4("ColtSusForma").ToString()
LungimeControl = SQLreader4("LungimeControl").ToString()
ProceduraApelata = SQLreader4("ProceduraApelata").ToString()
ControlId = SQLreader4("ControlId").ToString()
Dim TempButton As New Button()
TempButton.Name = "TempButton" & CStr(ControlId)
TempButton.Text = EtichetaControl
TempButton.Top = ColtSus
TempButton.Left = ColtStanga
TempButton.Width = LungimeControl
AddHandler TempButton.Click, AddressOf Executie
Loop
Private Sub Executie(ByVal sender As System.Object, ByVal e As System.EventArgs)
If TypeOf sender Is Button Then
' when i press the button i wish to execute stored procedure ProceduraApelata
End If
End Sub