473,811 Members | 2,820 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

User created control not working in form

5 New Member
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:
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 1291
David Gluth
46 New Member
Please post the ControlDataSour ce Property code block.
Dec 31 '10 #2
borri Craig
5 New Member
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
David Gluth
46 New Member
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.
Jan 5 '11 #4

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

Similar topics

1
1781
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 DB2. So, I created 2 new users using control centre and given all the authorities to those users. But, while creating users, it did not ask for password!!! how can i login/connect to the database with these users? Is there anything which i have to...
1
1115
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 method. but this method is invoked too if vs starts. not the best way. i need confirmation if the control is dropped to form during designtime for the first time. regardless if the the control is added via drag&drop or via double click.
0
2120
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
2272
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 itself are dynamically created controls. I create as follows: wcGroupControl oGroupControl = new wcGroupControl(); I then tried calling methods of the control passing dynamic controls as parameters that need to be added to the web controls on the...
2
2932
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 a WebForm with some textboxes, dropdownlists, a panel, imagebutton and so on. When I click on the image button (which was created at design time) I dynamically build a table. In each of row of that new table I put several cells and one cell...
7
7586
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 dynamically created dim c as control = me.Controls(strName) Instead I have to do this:
2
2774
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, properties and events. To the object I can use it, but it(he,she) cannot apply the User's Control inside the form of VB6. The function for this serious: Set objComNet.container = FormVB6 But the objComNet is of "read only" and therefore it is not...
3
4310
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 the the CodeBehind from that page: Dim mc As MainContent = New MainContent <----User Created Control
0
1142
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 form. This works good. Some times when I use the view Designer and bring up the form where this user defined user control should be in I get very surprised because the user defined control is not there it's gone .It's only one user defined
2
1687
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 Custom?
0
9724
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10644
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10394
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10127
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.