By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,966 Members | 1,975 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,966 IT Pros & Developers. It's quick & easy.

User created control not working in form

P: 5
I created a user control with a label and 2 combo boxes, and a public property called ControlDataSource 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:
Expand|Select|Wrap|Line Numbers
  1.         '
  2.         'UcDx1
  3.         '
  4.         Me.UcDx1.AutoSize = True
  5.         Me.UcDx1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink
  6.         Me.UcDx1.BackColor = System.Drawing.Color.Transparent
  7.         Me.UcDx1.ControlDataSource = Nothing
  8.         Me.UcDx1.LabelText = "Diag 1"
  9.         Me.UcDx1.Location = New System.Drawing.Point(1, 259)
  10.         Me.UcDx1.Margin = New System.Windows.Forms.Padding(0)
  11.         Me.UcDx1.Name = "UcDx1"
  12.         Me.UcDx1.SelectectedItemValue = ""
  13.         Me.UcDx1.Size = New System.Drawing.Size(289, 29)
  14.         Me.UcDx1.TabIndex = 3
  15.  
  16.  
The reference error is pointing to the line:

Expand|Select|Wrap|Line Numbers
  1. Me.UcDx1.ControlDataSource = Nothing
  2.  
  3.  
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.
Dec 30 '10 #1
Share this Question
Share on Google+
3 Replies


P: 46
Please post the ControlDataSource Property code block.
Dec 31 '10 #2

P: 5
Here is the property control block:

Expand|Select|Wrap|Line Numbers
  1.     Private dTable As DataTable
  2.  
  3.  
  4.     '<Description("Gets/Sets the dataset used by the dropdowns.")> _
  5.     Public Property ControlCBODataSource() As DataSet
  6.         Get
  7.             ControlCBODataSource = dsSet
  8.         End Get
  9.         Set(ByVal value As DataSet)
  10.  
  11.             dsSet = value.Copy
  12.             With cmbDX1
  13.                 .DataSource = dsSet.Tables(0)
  14.                 .DisplayMember = "DX"
  15.                 .ValueMember = "Description"
  16.             End With
  17.  
  18.             With cmbDX1Desc
  19.                 .DataSource = dsSet.Tables(0)
  20.                 .DisplayMember = "Description"
  21.                 .ValueMember = "DX"
  22.             End With
  23.         End Set
  24.     End Property
  25.  
Jan 3 '11 #3

P: 46
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.ControlDataSoruce = nothing. Obviously I am missing some of your code. Did you implement daSet as New Dataset?

Hope you get it figured out.
Jan 5 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.