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 / Design Time / August 2005

Tip: Looking for answers? Try searching our database.

Visual designer not setting values of custom control properties

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nadav Popplewell - 03 Aug 2005 10:28 GMT
I've got a strange problem with a custom control of mine.

The control got several properties, all of which a simple values (i.e. int
or string).

When I put the control on a form the code in the form InitializeCompoment()
is :

this.gridLayout21 = new BacSoft.Controls.GridLayout2();
((System.ComponentModel.ISupportInitialize)(this.gridLayout21)).BeginInit();
this.SuspendLayout();
//
// gridLayout21
//
this.gridLayout21.CellCaching = true;
this.gridLayout21.ColResizeInfo = "";
this.gridLayout21.Columns = 2;
this.gridLayout21.InnerPadding = 0;
.
.
.

It works perfectly when I run the application. All the properties are set
correctly.
The value of the column property is serialized to code properly,
but for some reason, when showing the form in the designer
the this.gridLayout.Columns Property is NOT set.
the other properties (CellCaching,ColResizeInfo,InnerPadding ) are set, but
Columns is not set.

I've tried debugging it (but openning another devenv and attaching to the
first devenv instance), and putting breakpoint in all the properties' set
accessors.
When openning the form in the debugged devenv The debugger stops on th
breakpoints in the CellCaching,ColResizeInfo,InnerPadding properties, but NOT
in the Columns property.

All my properties are defined with just the Browsable property:

[Browsable(true)]
public int Columns {
 get { return _cols; }
 set {
   if (value<0) {
     _cols=0;
   } else {
    _cols=value;
  }
  Arrange(true);
 }
}

[Browsable(true)]
public int InnerPadding {
 get { return _innerPadding; }
 set {
   bool ar=(_innerPadding!=value);
  _innerPadding=value;
  if (ar)
   Arrange(false);
 }
}

Can anybody think of anyway to fix this?

Thanks,
Nadav
Nadav Popplewell - 03 Aug 2005 11:47 GMT
OK, I' ve found the problem.

I had an interface:
public interface IGridControl {
 int Rows { get; }
 int Columns { get; }
}

which my Component implmented.

Apparently if the property implments a property of an interface the designer
fails to find this property (or does not recognize it as a property that
needs to be set).

When I changed the interface to
public interface IGridControl {
 int getRows();
 int getColumns();
}

then the designer initialized my component properties properly.

Is this behavior by design?

Is it possible that the designer got confused because the properties in the
interface were readonly ( int Rows { get; } ) but the properties of the
Component were Read/Write ( int Rows { get {..} set {..} } ) ?

Nadav

Rate this thread:







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.