User created control not working in form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • borri Craig
    New Member
    • Dec 2010
    • 5

    User created control not working in form

    I created a user control with a label and 2 combo boxes, and a public property called ControlDataSour ce that accepts a dataset - which it populates the combo boxes with. I added the reference to the VB project I want to use it on and to the toolbox. I was able to draw it on the form with no problem and use it. However, after changing the backcolor on the control and recompiling it, it is no longer seen by the form. When I bring up the form it's used on, I get a white screen with a bunch of xml. The problem seems to be in the designer, and I get an "object reference not set to an instance of an object" error. Here is the code from the designer:
    Code:
            '
            'UcDx1
            '
            Me.UcDx1.AutoSize = True
            Me.UcDx1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink
            Me.UcDx1.BackColor = System.Drawing.Color.Transparent
            Me.UcDx1.ControlDataSource = Nothing
            Me.UcDx1.LabelText = "Diag 1"
            Me.UcDx1.Location = New System.Drawing.Point(1, 259)
            Me.UcDx1.Margin = New System.Windows.Forms.Padding(0)
            Me.UcDx1.Name = "UcDx1"
            Me.UcDx1.SelectectedItemValue = ""
            Me.UcDx1.Size = New System.Drawing.Size(289, 29)
            Me.UcDx1.TabIndex = 3
    The reference error is pointing to the line:

    Code:
    Me.UcDx1.ControlDataSource = Nothing
    Here's the wierd part. If I hover the cursor over that property, it correctly identifies it as a dataset. So it does know what it is, but it can't seem to use it.

    Any ideas would be appreciated.
  • David Gluth
    New Member
    • Oct 2010
    • 46

    #2
    Please post the ControlDataSour ce Property code block.

    Comment

    • borri Craig
      New Member
      • Dec 2010
      • 5

      #3
      Here is the property control block:

      Code:
          Private dTable As DataTable
      
      
          '<Description("Gets/Sets the dataset used by the dropdowns.")> _
          Public Property ControlCBODataSource() As DataSet
              Get
                  ControlCBODataSource = dsSet
              End Get
              Set(ByVal value As DataSet)
      
                  dsSet = value.Copy
                  With cmbDX1
                      .DataSource = dsSet.Tables(0)
                      .DisplayMember = "DX"
                      .ValueMember = "Description"
                  End With
      
                  With cmbDX1Desc
                      .DataSource = dsSet.Tables(0)
                      .DisplayMember = "Description"
                      .ValueMember = "DX"
                  End With
              End Set
          End Property

      Comment

      • David Gluth
        New Member
        • Oct 2010
        • 46

        #4
        I played around with the info you gave and don’t see the problem, but then my implementation of your control is not producing the line me.UCDx1.Contro lDataSoruce = nothing. Obviously I am missing some of your code. Did you implement daSet as New Dataset?

        Hope you get it figured out.

        Comment

        Working...