Results 1 to 8 of 8

Thread: How to make several labels with a counter

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2007
    Location
    Belgium
    Posts
    154

    How to make several labels with a counter

    Hi,

    I want to make several linklabels for some links I have in a DB. I want the program make a new linklabel for each link automatically.

    I thought of something like this:

    static counter as integer
    Static point As Point

    point.X = 50
    point.Y = 70

    For Each dtrDatarowDVDs In objdtsAantalPerCategorie.tblCategorieën
    Dim linklabel(number of the counter) As New LinkLabel

    linklabel(number of the counter).Text = dtrDatarowDVDs.GetChildRows("tblDVDstblLinks").item("hyperlink")
    linklabel(number of the counter).Location = New Point(point.X, point.Y + 30)
    linklabel(number of the counter).Size = New Size(30, 30)
    Me.Controls.Add(linklabel(number of the counter))

    Next


    So what I want is that all my link stand under eachother. I don't know if I need a different label name for every linklabel.

    Maybe someone can help me

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Nov 2007
    Location
    Belgium
    Posts
    154

    Re: How to make several labels with a counter

    Hi,

    I want to make several linklabels for some links I have in a DB. I want the program make a new linklabel for each link automatically.

    I thought of something like this:
    vb Code:
    1. static counter as integer
    2. Static point As Point
    3.  
    4. point.X = 50
    5. point.Y = 70
    6.  
    7. For Each dtrDatarowDVDs In objdtsAantalPerCategorie.tblCategorieën
    8.      Dim linklabel(number of the counter) As New LinkLabel
    9.    
    10.      linklabel(number of the counter).Text = dtrDatarowDVDs.GetChildRows("tblDVDstblLinks").item("hyperlink")
    11.      linklabel(number of the counter).Location = New Point(point.X, point.Y + 30)
    12.      linklabel(number of the counter).Size = New Size(30, 30)
    13.      Me.Controls.Add(linklabel(number of the counter))
    14.  
    15. Next
    So what I want is that all my link stand under eachother. I don't know if I need a different label name for every linklabel.

    Maybe someone can help me

  3. #3
    Lively Member
    Join Date
    May 2008
    Posts
    75

    Re: How to make several labels with a counter

    you say you Thought of it... you didnt actually try out the code?


    Quote Originally Posted by kevin hash View Post
    Hi,

    I want to make several linklabels for some links I have in a DB. I want the program make a new linklabel for each link automatically.

    I thought of something like this:
    vb Code:
    1. static counter as integer
    2. Static point As Point
    3.  
    4. point.X = 50
    5. point.Y = 70
    6.  
    7. For Each dtrDatarowDVDs In objdtsAantalPerCategorie.tblCategorieën
    8.      Dim linklabel(number of the counter) As New LinkLabel
    9.    
    10.      linklabel(number of the counter).Text = dtrDatarowDVDs.GetChildRows("tblDVDstblLinks").item("hyperlink")
    11.      linklabel(number of the counter).Location = New Point(point.X, point.Y + 30)
    12.      linklabel(number of the counter).Size = New Size(30, 30)
    13.      Me.Controls.Add(linklabel(number of the counter))
    14.  
    15. Next
    So what I want is that all my link stand under eachother. I don't know if I need a different label name for every linklabel.

    Maybe someone can help me

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Nov 2007
    Location
    Belgium
    Posts
    154

    Re: How to make several labels with a counter

    The problem is I didn't try this code because I know it wont work. I don't know how to ad a number to the text "linklabel" when I declare it and when I use it later on. That is my problem. This is a code of what I want to do

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2007
    Location
    Belgium
    Posts
    154

    Re: How to make several labels with a counter

    Please help, I'm stuck on this. I've searched Google for hours now and still don't got an answer.

  6. #6
    Lively Member
    Join Date
    May 2008
    Posts
    75

    Re: How to make several labels with a counter

    Quote Originally Posted by kevin hash View Post
    Please help, I'm stuck on this. I've searched Google for hours now and still don't got an answer.
    you have your concepts all wrong

    ill help you out gimme a few mins while i enjoy my icecream

  7. #7
    Lively Member
    Join Date
    May 2008
    Posts
    75

    Re: How to make several labels with a counter

    Code:
    Const POINTX As Integer = 50
            Const POINTY As Integer = 70
    
            For i As Integer = 0 To 10
                Dim alinklabel As New LinkLabel
                alinklabel.Name = "LinkLabel" & i.ToString
                alinklabel.Text = "tblDVDstblLinks.hyperlink"
                alinklabel.Location = New Point(POINTX, POINTY + 30)
                alinklabel.Size = New Size(30, 30)
                Me.Controls.Add(alinklabel)
            Next

  8. #8
    Lively Member
    Join Date
    May 2008
    Posts
    75

    Re: How to make several labels with a counter

    and i you need to find any of the link lables to use later you can do a

    Code:
    Dim LabelIndex as integer = 1
    Dim FindMyLinkLabel As LinkLabel = Me.Controls("LinkLabel" & LabelIndex.ToString)

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