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 / Windows Forms / WinForm Controls / January 2006

Tip: Looking for answers? Try searching our database.

Having a hard time with DesignMode property

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Benton - 09 Jan 2006 17:23 GMT
Hi there,

I have a class that implements IComponent. When I drop this component from
the toolbox onto the form, I get a null exception while trying to access the
'Site.DesignMode property'. Site object seems to be null.

I believe my error should be pretty obvious (I must be missing something),
but I've tried dozens of code changes to no avail. Can't find a useful
example so I post a code excerpt here:

namespace Spaces
{
[DesignerAttribute(typeof(CustomerList.MyDesigner))]
public class CustomerList : BindingList<Customers>, IComponent
{
private ISite mSite;
public event EventHandler Disposed;
Persister pers;

public CustomerList()
{
 if (!this.Site.DesignMode) <== null exception here
 {
  // This should not run when adding the component to the form:
  pers = new Persister(this, GetSchema());
  Initialize();
 }
}

internal class MyDesigner : System.Windows.Forms.Design.ControlDesigner
{
 MyDesigner() { }
 public override void Initialize(IComponent component) {
base.Initialize(component); }
}

...more class code
}
}

I appreciate any help.

Regards,

-Benton
Andrew Smith (Infragistics) - 17 Jan 2006 04:36 GMT
The Site is a property of component but it cannot have been set while you
are still processing the constructor. You'll need to perform that check
later or perform that code and then if the Site property gets set, throw
away whatever information is not needed at design time.

> Hi there,
>
[quoted text clipped - 41 lines]
>
> -Benton

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.