I am developing a software that creates controls during runtime. I have used panels to place those controls. I use LABEL and a CHECKBOX to be created in runtime as sepecified by the user. They align one over the other as the checkbox over the label. [This is to allow the user to check the checkbox if they want to select the label]. When there are more number of such controls [crossing the screen], I made to stretch it in horizontal direction. Everything is perfect until now. The panel generated controls and they scroll. Now let me say that there can be 10 labels that my screen hold and to show more than that I have to scroll to make it visible. But the time comes, when i check the first check box and when I want to scroll to 18th label, the scrollbar automatically comes to the place where the 1st check box is checked and it doesnot give me enough time to check the 18th one neither. I couldn't understand this problem. Can anyone help me with it?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Panel1.Controls.Clear()
        Dim y As Integer = 10
        Dim x As Integer = 10
        'for loop starts here
            Dim l As New Label()
            Dim chk As New CheckBox()
            Try
                With l
                    .Location = New Point(x, y)
                    .Text = TextBox1.Text
                    .BackColor = Color.White
                    .TextAlign = ContentAlignment.MiddleCenter
                    .Height = 80
                    .Width = 200
                End With
                With chk
                    .Location = New Point(x, y)
                    .AutoSize = False
                    .Width = 15
                    .Height = 15
                End With
                If y < ScreenHeight - 300 Then
                    y = y + 110
                Else
                    x = x + 210
                    y = 10
                End If
                Panel1.Controls.Add(l)
                Panel1.Controls.Add(chk)
                AddHandler chk.CheckedChanged, AddressOf MyClickHandler
                lf.BringToFront()
                chk.BringToFront()
            Catch ex As Exception

            End Try
        Next
End Sub
   Private Sub MyClickHandler(ByVal Sender As Object, ByVal e As System.EventArgs)
        If Sender.Checked Then
            Form2.ListBox1.Items.Add(Sender.Text)
            SelectionCount = SelectionCount + 1
        Else
            Form2.ListBox1.Items.Remove(Sender.Text)
            SelectionCount = SelectionCount - 1
        End If

        If SelectionCount > 1 Then
            Button3.Enabled = True
        Else
            Button3.Enabled = False
        End If
    End Sub

The above is a piece of code where i generate the controls..

Recommended Answers

All 2 Replies

Can you post an image of the GUI. I am having a hard time visualizing what you are doing.

CPS Font Viewer

This is the actual application. You can find the problem in the opening form. Once the labels are generated for each fonts, the panels get filled with the styles. Scrolling is possible until you check any of the check box. If a check box is checked, then the focus of the page is on that check box only.

I think,

.tabstop=false

will do nothing. I tried it but in vain. Is there any other way for it?

Also in the software I used labels for displaying font styles. It consumes time for generation. Is there any other way I can display the font styles. Also labels do not support some fonts. I have to use exception handling to catch those exceptions and hide them not visible to the users. Thanks in advance.

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.