标签不包含location属性

时间:2018-09-11 02:52:28

标签: vb.net webforms

我使用VB.NET使用循环来创建多个标签。目前,我想水平更改标签位置,但是label1.location根本无法工作。它显示一个错误:

  

位置不是标签的成员。

标题属性也会发生同样的情况。它是WebForms应用程序(Visual Studio 2015)。

Sub countTable()
    Dim _dt As New DataTable
    fromdt = Me.fromdate.Text
    todt = Me.todate.Text
    model_no = Me.modelno.SelectedValue
    ' defect = Me.defectcode.SelectedValue

    gradeee = ""
    For Each item As ListItem In ll.Items
        If item.Selected Then
            gradeee += "'" & item.Text & "',"
            'message += item.Text + " " + item.Value + "\n"
        End If
    Next
    gradeee += "'test'"

    defect = Me.defectcode.SelectedValue
    classifi = ""
    For Each item As ListItem In mm.Items
        If item.Selected Then
            classifi += "'" & item.Text & "',"
            'message += item.Text + " " + item.Value + "\n"
        End If
    Next
    classifi += "'test'"
    'Me.Label1.Text = classifi

    _sql = " SELECT distinct TO_CHAR(S.TEST_TIME,'YYYY/MM/DD') AS period "
    _sql += " FROM CELLINT.CELL_TEST T "
    _sql += " LEFT OUTER JOIN CELLINT.CELL_TEST_YIELD S  "
    _sql += " ON S.SHEET_ID = T.SHEET_ID "
    _sql += " and S.TEST_TIME between to_date('" & fromdt & "','YYYY/MM/DD') and to_date('" & todt & "','YYYY/MM/DD') "
    If model_no <> "All" Then
        _sql += " and S.model_no = '" & model_no & "'"
    End If
    _sql += " and T.defect_code_desc || '(' || T.defect_code ||')'  = '" & defect & "'"

    If classifi.Contains("All") = True Then

    Else
        _sql += " and s.class in (" & classifi & ") "
        '_sql += " and class = '" & classifi & "' "
    End If
    If gradeee.Contains("All") = True Then

    Else
        _sql += " and t.grade in (" & gradeee & ") "
        '_sql += " and class = '" & classifi & "' "
    End If
    _sql += " order by TO_CHAR(S.TEST_TIME,'YYYY/MM/DD') asc "
    ' Response.Write(_sql)
    _dt = CIMDatabaseLink_USR.GetDataTable(_sql)

    count = _dt.Rows.Count - 1
    'Response.Write(_dt.Rows.Count - 1)

    For i = 0 To count
        Dim returnHTML As String = ""
        Dim myLabel As Label = New Label()

        period = "" & _dt.Rows(i).Item("period").ToString() & ""
        returnHTML = "<table><tr>"
        returnHTML = returnHTML & "<td><div>" & ReturnTable(period) & "</div><td>"
        returnHTML = returnHTML & "</tr></table>"

        myLabel.ID = "Label" & i & ""
        ' myLabel.Text = Server.HtmlDecode(ReturnTable(period))
        myLabel.Text = Server.HtmlDecode(returnHTML)
        myLabel.Location = New Point(7, 10)

        PlaceHolder1.Controls.Add(myLabel)
    Next
End Sub

0 个答案:

没有答案