Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / April 2008

Tip: Looking for answers? Try searching our database.

Question on UserControl

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dom - 23 Apr 2008 17:03 GMT
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
Ignacio Machin ( .NET/ C# MVP ) - 23 Apr 2008 22:52 GMT
> I've created a UserControl comprised of two controls, a DataGridView
> and a DateTimePicker.  I've done this because one of the columns in
[quoted text clipped - 22 lines]
>
> 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/aspnet/2/10013886/user-control-properties-i.aspx

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.