Problem rendering a form.

axeman69

Member
Joined
Apr 29, 2008
Messages
6
Programming Experience
10+
Hello all,

I am developing a windows form application that populates a GroupBox with fields from a database file (AS/400). When the user presses the "Connect" button, the program connects to the server, and populates a combo box with all of the libraries within a specified subset. When a library is selected from the CB, all of the files within a certain subset populates a second combo box. Up to this point, the program works fine. When the user makes a selection from the second combo box, the program will populate a group box with text boxes and labels for of the fields in the selected file. When this happens, Windows starts to really act funny. The text boxes won't show the data typed into them. And other open windows from other applications will render all black. I typically have to use Task Manager to close the application.

I should say that the app is running in the IDE. VS2008 on Windows 7 64 bit.

I've tried to develop this app in VS2012, VS2010, and VS2008. All with the same results.

Any ideas?

Thanks,
 
You are probably doing something wrong but as we don't know what you're doing, we can't possibly know what's wrong with it. Show us the actual code that gets executed when the issue occurs.

That said, it is the case that having a large number of controls displayed at the same time can cause issues. How many records are you dealing with? If it's thousands then that might be the problem. You should probably use a DataGridView in that case, which will only ever create a TextBox control when the user is editing a field, thus making the whole process more efficient.
 
Here is the code causing the problem. I will try a DataGridView as it may work better in this design.

VB.NET:
 Private Sub loadStructureFile(ByVal strLib As String, ByVal strFile As String)
        Dim strSQL As String = "SELECT Column_Name, Type_Name, Column_Size, Column_Text " & _
                              " FROM Sysibm.SQLColumns WHERE " & _
                              " Table_Schem = '" & strLib & "' AND TABLE_NAME = '" & strFile & "'"

        Dim cmd As New iDB2Command(strSQL, conMetalnet)
        Dim dr As iDB2DataReader


        Try
            dr = cmd.ExecuteReader
            If dr.HasRows Then
                Do While dr.Read
                    addToGroupBox2(dr.GetString(0), dr.GetString(1), dr.GetInt32(2), dr.GetString(3))
                    Application.DoEvents()
                Loop
            End If
        Catch ex As Exception

        End Try

    End Sub

    Private Sub addToGroupBox2(ByVal strName As String, ByVal strType As String, ByVal intSize As Int32, ByVal strText As String)
        Dim txtBox As New TextBox()
        Dim lbl As New Label()
        lbl.Text = strText.Trim & " (" & strName.Trim & ")"
        lbl.Location = New Point(intX, intY)
        lbl.Size = New System.Drawing.Size(strText.Trim.Length * 8.25, 20)
        txtBox.Name = strName
        txtBox.MaxLength = intSize
        txtBox.Size = New System.Drawing.Size(intSize * 8.25, 20)
        txtBox.Location = New Point(intX + (lbl.Size.Width + 5), intY)
        GroupBox2.Controls.Add(lbl)
        GroupBox2.Controls.Add(txtBox)


    End Sub
 
Back
Top