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
        Dim y As Integer = 10
        Dim x As Integer = 10
        'for loop starts here
            Dim l As New Label()
            Dim chk As New CheckBox()
                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
                    x = x + 210
                    y = 10
                End If
                AddHandler chk.CheckedChanged, AddressOf MyClickHandler
            Catch ex As Exception

            End Try
End Sub
   Private Sub MyClickHandler(ByVal Sender As Object, ByVal e As System.EventArgs)
        If Sender.Checked Then
            SelectionCount = SelectionCount + 1
            SelectionCount = SelectionCount - 1
        End If

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

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

5 Years
Discussion Span
Last Post by Riteman

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,


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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.