label does not contain location property

label does not contain location property



I use a loop to create multiple labels using VB.NET. Currently, I want to change the labels position horizontally, but the label1.location is not working at all. It shows an error saying:


label1.location



location is not member of label.



The same happens with the caption property. It's WebForms application (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






Hello Chris, welcome to StackOverflow! Please show us your code so we can help you with it. Here are some topics that would help you refine your question: How to ask and How to create a Minimal, Complete, and Verifiable example.

– Ahmed Abdelhameed
Sep 11 '18 at 2:56






There's not enough information here to help. You need to provide much more information. Project type. Code that is causing the error. Anything else of relevance.

– Sam Axe
Sep 11 '18 at 2:56






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

– ChrisYQ
Sep 11 '18 at 2:59






It shows error at myLabel.location

– ChrisYQ
Sep 11 '18 at 3:00






@ChrisYQ Please edit your question and include your code there (make sure it's properly formatted), and also mention the project type (WinForms, WPF, WebForms, etc.).

– Ahmed Abdelhameed
Sep 11 '18 at 3:03




1 Answer
1


myLabel.Style.Add("position" , "absolute")
myLabel.Style.Add("top" , "7px")
myLabel.Style.Add("left" , "10px")



Those are just some examples, but try something like that via code-behind to change the style of the label.



You could also use to do them all


myLabel.Attributes.Add("style" , "top: 7px; left: 10px; position: absolute;")



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ