472,977 Members | 1,913 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Question on UserControl

Dom
I've created a UserControl comprised of two controls, a DataGridView
and a DateTimePicker. I've done this because one of the columns in
the DataGridView will hold a date, and when the user clicks on the
column, the DateTimePicker will appear.

Now for the problem.

I want the main program to add columns (and other properties) to the
DataGridView control. So I exposed the control, like this (where
dgvMain is the name of the DataGridView control in the UserControl):

public DataGridView GridControl
{
get {return dgvMain;}
}

This is fine. The properties box of the UserControl now has
"GridControl" which opens to the usual properties of a datagridview.
But when I click on "Columns" in the properties box, I get the message
"Object reference not set to an instance of an object." The odd thing
is, I can add columns in code. (Or maybe that's not so odd).

How do I handle this?

Dom
Jun 27 '08 #1
1 1160
On Apr 23, 12:03*pm, Dom <dolivas...@gmail.comwrote:
I've created a UserControl comprised of two controls, a DataGridView
and a DateTimePicker. *I've done this because one of the columns in
the DataGridView will hold a date, and when the user clicks on the
column, the DateTimePicker will appear.

Now for the problem.

I want the main program to add columns (and other properties) to the
DataGridView control. *So I exposed the control, like this (where
dgvMain is the name of the DataGridView control in the UserControl):

public DataGridView GridControl
{
* * *get {return dgvMain;}

}

This is fine. *The properties box of the UserControl now has
"GridControl" which opens to the usual properties of a datagridview.
But when I click on "Columns" in the properties box, I get the message
"Object reference not set to an instance of an object." *The odd thing
is, I can add columns in code. *(Or maybe that's not so odd).

How do I handle this?

Dom
Hi,

Not that's not odd at all :)

you can use it from code with no problem, if you want to use the
designer well, it's a completely different history, you need to
implement at least one interface.
Take a look at MSDN or this article
http://www.eggheadcafe.com/community...perties-i.aspx
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chris | last post by:
I have a question on whether or not this is good practice. I have a fairly complex web user control (a datalist embedded in a datalist with lots of controls) that I will call Usercontrol1 and a...
1
by: Chowny | last post by:
I am fairly new to ASP .NET, and am busy teaching myself as I work through my current project. I'm a bit stumped at the moment. I have made a usercontrol called "RelatedClaims" . The code as...
2
by: Sascha | last post by:
Hi there, I searched carefully through the web before finally deciding to post this message, because I could not find a solution for my problem. Hopefully someone will have a hint or explanation...
0
by: Patrick.O.Ige | last post by:
The SignOut() button below doesn't fire if in a UserControl but if i move it to an ASPX page it fires.. It seems i can't get access to the SUB in the USERCONTROL. Am i missing something? Any...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
3
by: Gary Kahrau | last post by:
I hope this is a simple question. I have a number of usercontrols placed on a form. The usercontrol has a public property (DispMachine) within it. When looping through the main form controls, I...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
2
by: Mark Collard | last post by:
The ToolBar control allows you to add toolbar buttons. When you add a button, the button is not only displayed in the toolbar, but also added as a separator control in the form/usercontrol your...
7
by: John D'oh | last post by:
Hello, I have been going through the MSDN Walkthrough: Creating a Windows Forms Control That Takes Advantage of Visual Studio Design-Time Features. Everything was going fine and I was able to...
2
by: =?Utf-8?B?TWFyayBDb2xsYXJk?= | last post by:
I've created a usercontrol with a Person property. The Person property returns a Person object. I've also created a PersonConverter class which inherits the ExpandableObjectConverter so the Person...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.