the text of dynamic label is not complete , why???
I create graphics variablt to measure size of text , than, I set the width and heigh , ??

Public Class Form1
    Dim counter As Integer=3 'suppose counter=number of columns in 2-dimention 
    Dim g As Graphics
    Dim d As Integer
    Dim s As SizeF
    Dim l1 As Label
    Dim array1() = {"c1", "c2", "c3"}
    Dim frag_des(,) As String = {{"c1", "c2", "c3"}, {"ddddddddddd ", "ffffffffff ", "ggggggggggggggg"}}

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For j As Integer = 0 To array1.Length - 1
            d = 0
            l1 = New Label()
            
            
            While Not (array1(j) = frag_des(0, d)) And d < counter
                'frag_des.GetUpperBound(0)
                d += 1
            End While

            If Not (array1(j) = frag_des(0, d)) Then
                g = l1.CreateGraphics
                s = g.MeasureString(array1(j), l1.Font)
                l1.Height = s.Height
                l1.Width = s.Width
                l1.Text = array1(j)
            Else
                g = l1.CreateGraphics
                s = g.MeasureString(array1(j) & ": " & frag_des(1, d), l1.Font)
                l1.Height = s.Height
                l1.Width = s.Width
                l1.Text = array1(j) & ": " & frag_des(1, d)
                MsgBox(array1(j) & ": " & frag_des(1, d))
            End If

            l1.Location = New Point(5, (j * 25) + 3)



            Me.Controls.Add(l1)
        Next
    End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.