I have an array of panels from which I can easily select any panel I want. On each panel I have a label. Is there a way I can access the child label from its parent panel. (I want to access the text on the label). It seems to me there should be some simple code to do this?
You can access the label text directly via LabelName.Text regardless if it is a child of a panel. If it is added through designer you need to generate the declaration
You can access the label text directly via LabelName.Text regardless if it is a child of a panel. If it is added through designer you need to generate the declaration
Thanks but I don't know the name of the label. I rotate through a bunch of panels and I want to click on the label on each panel and then get its text to sound out using tts. The problem is I don't know the name of the label but I can identify its parent label from its position in the array of panelviews from which I selected it. If there is a way to get the text in the click event without knowing the name of the label that triggered it that would answer the problem?
Then what Roycefer pointed out is what you need. However this will only work if each panel only contains 1 label. If there are multiple labels then you won't know which one to edit unless you use its name/tag
Then what Roycefer pointed out is what you need. However this will only work if each panel only contains 1 label. If there are multiple labels then you won't know which one to edit unless you use its name/tag
OK. I got it now. My code is now
Dim lv As Label = panels(n).getview(1)
lv.Initialize("")
Dim word As String
lv=Sender
word=lv.Text
Thanks Roycefer and JonPM !!
Dim lv As Label = panels(n).getview(1)
lv.Initialize("")
as when you assign sender to lv, the previous assignment is overwritten, you only need the two lines in my previous post.
In fact, just for clarity, the first line will get the second view from panel (zero based), the Initialize in the second line will overwrite that, then the (correct) assignment of sender to lv will be the one that is left and working.
Dim lv As Label = panels(n).getview(1)
lv.Initialize("")
as when you assign sender to lv, the previous assignment is overwritten, you only need the two lines in my previous post.
In fact, just for clarity, the first line will get the second view from panel (zero based), the Initialize in the second line will overwrite that, then the (correct) assignment of sender to lv will be the one that is left and working.