473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

User created control not working in form

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
3 1279
Please post the ControlDataSource Property code block.
Dec 31 '10 #2
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
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

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

Similar topics

1
by: Praveen | last post by:
Hi All, I have a server DB2 UDB V8 on sun box. and accessing the server using DB2 UDB client 7 from win2k system. Till now i used to login using db2inst1 user which a default user created by...
1
by: Daniel Weinand | last post by:
hi, i need an event when a user is dropping a control to the form. i have a button derived from Form.Button. in my own designer i try to catch this event. at the moment im using the initilaize...
0
by: John Crowley | last post by:
I'm having an odd problem with viewstate and a dynamically created control inside a repeater template. Basically, I have a repeater setup like this in the aspx:
3
by: Eric | last post by:
I have built a composite user web control that I want to create dynamically. The form will contain a variable number of these controls and as well some of the contents of the user web control...
2
by: R Duke | last post by:
I have tried everything I can think of to change the visible property of a design time created control from a dynamically created control's command event handler. Here is the scenario. I have...
7
by: mef526 | last post by:
I would like to reference a dynamically created control and I know the name. I would like to use the following: Dim strName as String = "txtControl1" ' This is the ".Name" used when textbox was...
2
by: damianmatiasmax | last post by:
Hola, I am trying to generate a UserControl in VB.NET to be able to use it in VB6. Therefore: 1- I generate the Wrapper and the object COM 2- Import it from VB6 and I can use his methods,...
3
by: RSH | last post by:
Hi, I have a situation where I have a page built in .Net 1.1 that I have a PlaceHolder in the Design. From the CodeBehind I am dynamically referencing a user control. This is a snippet from...
0
by: tony | last post by:
Hello! For some month ago I created a project using template Window Control Library. From this template I created a user control(DLL) that I have in the toolbox and can drag it into a window...
2
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I think if the object type of the control is not System.Windows.Forms.xxx, then it is a user-defined control. But how to tell the type of the user-defined control: Composite(User), Extended, and...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.