VB: User Control Object Reference Error with Datagridview

560 views Asked by At

I'm working in Visual Studio 2010 with Visual Basic. I have a Windows Form and a User Control. On the User Control is a Datagridview, which is linked to a table, which is Public Shared.

When putting the User Control on the Windows Form I get the following Message, displayed where my Form was:

To prevent possible data loss before loading the designer, the following errors must be resolved: Object reference not set to an instance of an object.

at Fehlteilmanagement.CheckMultiple.CheckMultiple_Load(Object sender, EventArgs e) in C:\Users\TO113808\Desktop\Fehlteilmanagement\Visual Studio\Fehlteilmanagement\Fehlteilmanagement\Forms\CheckMultiple.vb:line 7 at System.Windows.Forms.UserControl.OnLoad(EventArgs e) at System.Windows.Forms.UserControl.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.ControlCollection.Add(Control value) at System.Windows.Forms.Form.ControlCollection.Add(Control value) at System.Windows.Forms.Design.ControlDesigner.DesignerControlCollection.Add(Control c)

I know that it has something to do with my UserControl_Load Function, currently it looks like this:

        DGV_MultipleFT.DataSource = tableMultipleLinesFT
    DGV_MultipleFT.Columns("Neu").Visible = False

    For i = 0 To tableMultipleLinesFT.Rows.Count - 1
        If Not IsDBNull(tableMultipleLinesFT.Rows(i).Field(Of Boolean?)("Neu")) And tableMultipleLinesFT.Rows(i).Field(Of Boolean?)("Neu") = True Then
            DGV_MultipleFT.RowsDefaultCellStyle.BackColor = Color.GreenYellow
        End If

If I delete the Changes in the DatagridView (DGV_MultipleFT) everything is fine. Even though i get the Error-Message, my Program compiles fine and works. But I want to ask what i can do about it.

If you want to have my Designer.vb I will post it, but if someone has an Idea, I would be very thankful.

Best Regards

0

There are 0 answers