Results 1 to 2 of 2

Thread: Dynamic controls & their properties

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2002
    Location
    Florida
    Posts
    16

    Lightbulb Dynamic controls & their properties

    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.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Jun 2002
    Location
    Florida
    Posts
    16

    Talking Z-index

    I answer myself...

    Z-index, as with all CSS attributes can be set via
    myControl.Style.Item(myAttribute) =
    e.g.
    myControl.Style.Item("Z-Index") = "200"
    You must also have
    myControl.Style.Item("position") = "absolute"

    Thank me very much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width