Doing a simplistic 'extender provider'
-
I've really tried to make sense out of the extender provider samples, but not a one of them does the same way, and none of them are relatively trivial. What I am looking for is the ability to add one simple 'boolean' to every object on my form. Sounds simple... So what am I doing wrong? I added on a project to my main application and created a component of out this. I can get it to show up, but in no combination of aggravation can I make the boolean property appear on the controls. Can anyone help me out! Thanks!! ---------------------------------------------- using System; using System.ComponentModel; using System.Windows.Forms; namespace StatusMessage { [ProvideProperty( "StatusMessage", typeof( Object ))] public class StatusMessaging : Component, IExtenderProvider { private bool bUpdateStatusBar = false; [DefaultValue(false)] public bool GetStatusMessage( Control pControl ) { return bUpdateStatusBar; } public void SetStatusMessage( Control pControl, bool value ) { bUpdateStatusBar = value; } public bool CanExtend( object pControl ) { if( pControl is Component ) return true; else return false; } } }
-
I've really tried to make sense out of the extender provider samples, but not a one of them does the same way, and none of them are relatively trivial. What I am looking for is the ability to add one simple 'boolean' to every object on my form. Sounds simple... So what am I doing wrong? I added on a project to my main application and created a component of out this. I can get it to show up, but in no combination of aggravation can I make the boolean property appear on the controls. Can anyone help me out! Thanks!! ---------------------------------------------- using System; using System.ComponentModel; using System.Windows.Forms; namespace StatusMessage { [ProvideProperty( "StatusMessage", typeof( Object ))] public class StatusMessaging : Component, IExtenderProvider { private bool bUpdateStatusBar = false; [DefaultValue(false)] public bool GetStatusMessage( Control pControl ) { return bUpdateStatusBar; } public void SetStatusMessage( Control pControl, bool value ) { bUpdateStatusBar = value; } public bool CanExtend( object pControl ) { if( pControl is Component ) return true; else return false; } } }
Let me update the code. After 300 iterations, it just didn't look right namespace StatusMessage { /// /// Summary description for UserControl1. /// [ProvideProperty( "StatusMessage", typeof( bool ))] public class StatusMessaging : Component, IExtenderProvider { /// /// Required designer variable. /// protected bool bUpdateStatusBar = false; public bool GetStatusMessage( Control pControl ) { return bUpdateStatusBar; } public void SetStatusMessage( Control pControl, bool value ) { bUpdateStatusBar = value; } public bool CanExtend( object pControl ) { if( pControl is Control ) return true; return false; } } }
-
Let me update the code. After 300 iterations, it just didn't look right namespace StatusMessage { /// /// Summary description for UserControl1. /// [ProvideProperty( "StatusMessage", typeof( bool ))] public class StatusMessaging : Component, IExtenderProvider { /// /// Required designer variable. /// protected bool bUpdateStatusBar = false; public bool GetStatusMessage( Control pControl ) { return bUpdateStatusBar; } public void SetStatusMessage( Control pControl, bool value ) { bUpdateStatusBar = value; } public bool CanExtend( object pControl ) { if( pControl is Control ) return true; return false; } } }
psdavis wrote: [ProvideProperty( "StatusMessage", typeof( bool ))] Try making it typeof(Control). You need to tell the UI what type of objects you want the property to appear for. It works out the type your property will provide from the GetStatusMessage and its return type. I can send you an example I have that I wrote which provides a simple extender to a control. I was going to write it up as an article, but I dont haev time. -- David Wengier Sonork ID: 100.14177 - Ch00k