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 / July 2006

Tip: Looking for answers? Try searching our database.

Setting GenerateMember property from ControlDesigner derived class

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vladimir.khvostov@gmail.com - 18 Jul 2006 01:07 GMT
Hi,
I implemented a simple control - HorizontalBevel that can be used to
render horizontal lines on a form (2 pixel in Height). I wanted to
display only what make sense for this control in properties window, so
I wrote a HorizontalBevelDesigner class, which removes most properties
by overriding PostFilterProperties() method.

I also want to set GenerateMember to false, so that only local variable
is generated in the InitializeComponent(), instead of member variable.

Sound simple, but already spent about 45min. trying to figure this out.
Neither Component nor ComponentDesigner have this property.

Regards,
-- Vladimir
Vladimir Khvostov - 18 Jul 2006 05:14 GMT
OK. Found out how to do this:
If someone is interested:

       bool SetGenerateMemberProperty(bool value)
       {
           IExtenderListService service =
(IExtenderListService)this.GetService(typeof(IExtenderListService));

           IExtenderProvider provider =
Array.Find<IExtenderProvider>(service.GetExtenderProviders(),
               delegate(IExtenderProvider item) { return
item.GetType().FullName ==
"System.ComponentModel.Design.Serialization.CodeDomDesignerLoader+ModifiersExtenderProvider";
});

           MethodInfo methodInfo =
provider.GetType().GetMethod("SetGenerateMember", BindingFlags.Public |
BindingFlags.Instance);

           if (methodInfo != null)
           {
               methodInfo.Invoke(provider, new object[] { base.Component,
false });
               return true;
           }

           return false;
       }

-- Vladimir

> Hi,
> I implemented a simple control - HorizontalBevel that can be used to
[quoted text clipped - 11 lines]
> Regards,
> -- Vladimir
Roman - 18 Jul 2006 06:37 GMT
Hi Vladimir.
Thank you for this sample. It is useful for me.
Signature

Thanks Roman
--

> OK. Found out how to do this:
> If someone is interested:
[quoted text clipped - 42 lines]
>> Regards,
>> -- Vladimir

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.