PopsMcF
Jun 21st, 2002, 07:46 PM
Hi All,
I'm dynamically laying down a stack of text boxes where the top of the next box is just below the bottom of the previous one. I want to assign the height of the previous textbox to an integer variable iNewTop then assign iNewTop to the top property of the next textbox.
1. What is the best-practice to return the height of a textbox to assign it to my integer variable iNewTop? e.g...
iNewTop += CType(.Height, Integer) ' this is not correct
iNewTop += CInt(left(arrtextboxes(i).Height.ToString,2)) ' this works but assumes string contains 2 digits
iNewTop += CInt(Val(arrTextBoxes(i).Height.ToString)) ' this works
2. What is the best-practice to set the "top" property? I'm using
.Style.Item("top") = iNewTop.ToString & "px"
3. How can I set the Z-inder of a control to be sure it is on top?
Here's my code...
Private Sub Display_TextBoxes()
' variation from online help
Dim i As Integer = 1
Dim iCtrlCount As Integer = 5
Dim iNewTop As Int32 = 100
For i = 1 To iCtrlCount
Dim arrTextBoxes(5) As TextBox ' = New TextBox()
arrTextBoxes(i) = New TextBox()
' Set the Text and ID properties for textbox.
With arrTextBoxes(i)
.Text = "hello Dave"
.ID = "txt" & i
.Height = New Unit("20px")
.Style.Item("top") = iNewTop.ToString & "px" ' is this the best way?
.Style.Item("left") = "8px"
.Style.Item("position") = "absolute"
'''iNewTop += CType(.Height, Integer) ' this is not correct
'''iNewTop += CInt(Left(arrTextBoxes(i).Height.ToString, 2)) ' this works but assumes string contains 2 digits
iNewTop += CInt(Val(arrTextBoxes(i).Height.ToString)) + 5 ' is this the best way?
.Visible = True
End With
Me.FindControl("Form1").Controls.Add(arrTextBoxes(i))
Next
End Sub ' Display_TextBoxes()
Thank you all.
I'm dynamically laying down a stack of text boxes where the top of the next box is just below the bottom of the previous one. I want to assign the height of the previous textbox to an integer variable iNewTop then assign iNewTop to the top property of the next textbox.
1. What is the best-practice to return the height of a textbox to assign it to my integer variable iNewTop? e.g...
iNewTop += CType(.Height, Integer) ' this is not correct
iNewTop += CInt(left(arrtextboxes(i).Height.ToString,2)) ' this works but assumes string contains 2 digits
iNewTop += CInt(Val(arrTextBoxes(i).Height.ToString)) ' this works
2. What is the best-practice to set the "top" property? I'm using
.Style.Item("top") = iNewTop.ToString & "px"
3. How can I set the Z-inder of a control to be sure it is on top?
Here's my code...
Private Sub Display_TextBoxes()
' variation from online help
Dim i As Integer = 1
Dim iCtrlCount As Integer = 5
Dim iNewTop As Int32 = 100
For i = 1 To iCtrlCount
Dim arrTextBoxes(5) As TextBox ' = New TextBox()
arrTextBoxes(i) = New TextBox()
' Set the Text and ID properties for textbox.
With arrTextBoxes(i)
.Text = "hello Dave"
.ID = "txt" & i
.Height = New Unit("20px")
.Style.Item("top") = iNewTop.ToString & "px" ' is this the best way?
.Style.Item("left") = "8px"
.Style.Item("position") = "absolute"
'''iNewTop += CType(.Height, Integer) ' this is not correct
'''iNewTop += CInt(Left(arrTextBoxes(i).Height.ToString, 2)) ' this works but assumes string contains 2 digits
iNewTop += CInt(Val(arrTextBoxes(i).Height.ToString)) + 5 ' is this the best way?
.Visible = True
End With
Me.FindControl("Form1").Controls.Add(arrTextBoxes(i))
Next
End Sub ' Display_TextBoxes()
Thank you all.