By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,165 Members | 1,928 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,165 IT Pros & Developers. It's quick & easy.

"friend" accessor and inherited forms

P: n/a
Interesting behavior I came across today where a child form has full access
to a base form class' controls, but you can only modify the controls'
properties in code, not in the visual designer. Here's how you can reproduce
it:

New Winforms project
On Form1, drop a visual control. I'll use a panel in this example.
Make sure Panel1 modifier is set to "Friend"
Build project
Add another form - this one an inherited form. Set it to inherit from Form1.

At this point, you can go to the Form2 code editor and you will indeed have
full access to Me.Panel1 and all its properties.

However, if you go to the visual designer of Form2 and click on Panel1,
you'll notice in the F4 properties window, all of the properties are greyed
out as if Panel1 was declared "Private".

After some searching here, I noticed that this was identified as a bug in
VB.NET 2003, however, the same behavior happens in 2005 as well. Is this
still considered a bug? Or has it been upgraded to "feature"? :)
Feb 1 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Vark,

Can you give us the link where this was notified as a bug in version 2003.

As you describe it, does it looks for me so obvious that you cannot change
the properties from a base class inside a derived object, in another way
than overriding it if that is possible.

Cor
Feb 1 '06 #2

P: n/a
I'm using the web interface for these newsgroups, so I don't know how to link
to an article, however, if you search against "protected friend" in the
dotnet.framework.windowsforms group, there's a thread titled "Inherited Menus
and Modifiers" where someone mentions it being in an internal bug database.

However, now that I read that, that post does specify "protected friend"
which may or may not work these days. That's moot, though since I can't use
protected friend (I don't want child classes outside the assembly to have
access). I unfortunately am limited to using friend only.

I've used a temporary work around - set it as protected, which gives me
designer support, then right before the build copy all the
InitializeComponent code for that control into the Form New() and change the
control to friend. It works for now, but it does seem a bit kludgy to do it
this way.

"Cor Ligthert [MVP]" wrote:
Vark,

Can you give us the link where this was notified as a bug in version 2003.

As you describe it, does it looks for me so obvious that you cannot change
the properties from a base class inside a derived object, in another way
than overriding it if that is possible.

Cor

Feb 1 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.