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

How can I make a property not show in the properties window?

P: n/a
I made a Usercontrol that must have AutoScroll set to true when it is used.
So I set it to True in the Load event.

However the property still shows in the properties window when the control
is placed on a form.

That's confusing.

How can I make that property not show in the properties window?
Thanks in advance for any useful info
Nov 21 '05 #1
Share this Question
Share on Google+
27 Replies


P: n/a
Use the browsable attribute. For example:

<Browsable(False)>_
Public Property Name() as String
Get ...
Set...
End Property

Ron

" Just Me" <gr****@a-znet.com> wrote in message
news:Oa**************@TK2MSFTNGP15.phx.gbl...
I made a Usercontrol that must have AutoScroll set to true when it is used. So I set it to True in the Load event.

However the property still shows in the properties window when the control
is placed on a form.

That's confusing.

How can I make that property not show in the properties window?
Thanks in advance for any useful info

Nov 21 '05 #2

P: n/a
" Just Me" <gr****@a-znet.com> schrieb:
I made a Usercontrol that must have AutoScroll set to true when it is used.
So I set it to True in the Load event.

However the property still shows in the properties window when the control
is placed on a form.
[...] How can I make that property not show in the properties window?

\\\
Imports System.ComponentModel
..
..
..
<Browsable(False)> _
Public Property...
///

If the property should not appear in the text editor too, add the
'EditorBrowsable' attribute too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3

P: n/a
Am I missing something?
Where would I place <Browsable(False)>
The AutoScroll property comes with the UserControl.
I don't generate it.
Thanks
BTW will <Browsable(False)> keep the designer from assigning a value to the
property that <Browsable(False)> is assigned to?

" Just Me" <gr****@a-znet.com> wrote in message
news:Oa**************@TK2MSFTNGP15.phx.gbl...
I made a Usercontrol that must have AutoScroll set to true when it is used.
So I set it to True in the Load event.

However the property still shows in the properties window when the control
is placed on a form.

That's confusing.

How can I make that property not show in the properties window?
Thanks in advance for any useful info

Nov 21 '05 #4

P: n/a
" Just Me" <gr****@a-znet.com> schrieb:
Am I missing something?
Where would I place <Browsable(False)>
The AutoScroll property comes with the UserControl.
I don't generate it.


Untested:

\\\
<Browsable(False)> _
Public Overrides Property AutoScroll() As Boolean
Get
Return MyBase.AutoScroll
End Get
Set(ByVal Value As Boolean)
MyBase.AutoScroll = Value
End Set
End Property
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #5

P: n/a
AutoScroll cannot be overridden!

"Herfried K. Wagner [MVP]" wrote:
" Just Me" <gr****@a-znet.com> schrieb:
Am I missing something?
Where would I place <Browsable(False)>
The AutoScroll property comes with the UserControl.
I don't generate it.


Untested:

\\\
<Browsable(False)> _
Public Overrides Property AutoScroll() As Boolean
Get
Return MyBase.AutoScroll
End Get
Set(ByVal Value As Boolean)
MyBase.AutoScroll = Value
End Set
End Property
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #6

P: n/a
"Dennis" <De****@discussions.microsoft.com> schrieb:
AutoScroll cannot be overridden!


Mhm... The code compiles as part of a usercontrol in .NET 1.1.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #7

P: n/a
Dennis,
If you want to "override" the *attributes* of a not overridable property.

You can Shadow the property.
<Browsable(False)> _
Public Shadows Property AutoScroll() As Boolean
Get
Return MyBase.AutoScroll
End Get
Set(ByVal Value As Boolean)
MyBase.AutoScroll = Value
End Set
End Property

Note: Shadowing a property to change the attributes is one of the few times
when you need to "design" with Shadows. Otherwise Shadows should be reserved
for version control...

However as Herfried suggests, Control.AutoScroll is overridable in VB.NET
2003.

Hope this helps
Jay

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com... AutoScroll cannot be overridden!

"Herfried K. Wagner [MVP]" wrote:
" Just Me" <gr****@a-znet.com> schrieb:
> Am I missing something?
> Where would I place <Browsable(False)>
> The AutoScroll property comes with the UserControl.
> I don't generate it.


Untested:

\\\
<Browsable(False)> _
Public Overrides Property AutoScroll() As Boolean
Get
Return MyBase.AutoScroll
End Get
Set(ByVal Value As Boolean)
MyBase.AutoScroll = Value
End Set
End Property
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #8

P: n/a

Otherwise Shadows should be reserved for version control...

Seems I remember wanting a control to have a MouseMove event so I Shadowed
the inherited event

Does that sound like I should have done something else?

Nov 21 '05 #9

P: n/a
Just Me,
Does that sound like I should have done something else? Possibly, without more details I really can't answer this.

Control already has a MouseMove event, why were you shadowing it?

You can call Control.OnMouseMove to raise the Control.MouseMove event...
The "problem" with Shadowing is it is anti-polymophism, in that is
explicitly does not behave polymorphically. In other words it rarely behaves
the way you expect it to.

In Herfried's example, his shadowing property was simply calling the base
property, thus not needing polymorphism...

Hope this helps
Jay

" Just Me" <gr****@a-znet.com> wrote in message
news:ut***************@TK2MSFTNGP10.phx.gbl...
Otherwise Shadows should be reserved for version control...

Seems I remember wanting a control to have a MouseMove event so I Shadowed
the inherited event

Does that sound like I should have done something else?

Nov 21 '05 #10

P: n/a

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:uK**************@TK2MSFTNGP14.phx.gbl...
Just Me,
Does that sound like I should have done something else?

Possibly, without more details I really can't answer this.

Control already has a MouseMove event, why were you shadowing it?

I don't remember, It may have been MouseUp or Down and maybe I wanted to
provide different data.

I was just cautious about your comment.
Thanks
Nov 21 '05 #11

P: n/a
Always a complication. I added the code below and built it. Created a new
form and added the revised control to it.
The two properties do not appear in the properties list - great.
However, AutoScroll does not appear in the code listing, why not?
Also, AutoScrollMargin does appear in the code listing, I thought
EditorBrowsable would supress it

<Browsable(False)> _
Public Overrides Property AutoScroll() As Boolean
Get
Return MyBase.AutoScroll
End Get
Set(ByVal value As Boolean)
MyBase.AutoScroll = value
End Set
End Property

<Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
Public Shadows Property AutoScrollMargin() As Size
Get
Return MyBase.AutoScrollMargin
End Get
Set(ByVal value As Size)
MyBase.AutoScrollMargin = value
End Set
End Property
Nov 21 '05 #12

P: n/a
Just Me,
What specifically do you mean "appear in the code listing"?

Do you mean Intellisense or the "Windows Forms Generated Code" region?

EditorBrowsable controls Intellisense.

DefaultValue controls the "Windows Forms Generated Code" region.

It might be that Intellisense is not as intelligent as the Property Grid
when it comes to Shadows & properties.

Hope this helps
Jay

" Just Me" <gr****@a-znet.com> wrote in message
news:eO**************@TK2MSFTNGP14.phx.gbl...
Always a complication. I added the code below and built it. Created a new
form and added the revised control to it.
The two properties do not appear in the properties list - great.
However, AutoScroll does not appear in the code listing, why not?
Also, AutoScrollMargin does appear in the code listing, I thought
EditorBrowsable would supress it

<Browsable(False)> _
Public Overrides Property AutoScroll() As Boolean
Get
Return MyBase.AutoScroll
End Get
Set(ByVal value As Boolean)
MyBase.AutoScroll = value
End Set
End Property

<Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
Public Shadows Property AutoScrollMargin() As Size
Get
Return MyBase.AutoScrollMargin
End Get
Set(ByVal value As Size)
MyBase.AutoScrollMargin = value
End Set
End Property

Nov 21 '05 #13

P: n/a

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:eM**************@TK2MSFTNGP14.phx.gbl...
Just Me,
What specifically do you mean "appear in the code listing"?

Do you mean Intellisense or the

I meant this."Windows Forms Generated Code" region? I was hoping to stop the code generation/apperance. Doesn't DefaultValue
only effect the value assigned in the code generated?


EditorBrowsable controls Intellisense.

DefaultValue controls the "Windows Forms Generated Code" region.

It might be that Intellisense is not as intelligent as the Property Grid
when it comes to Shadows & properties.

Hope this helps
Jay

" Just Me" <gr****@a-znet.com> wrote in message
news:eO**************@TK2MSFTNGP14.phx.gbl...
Always a complication. I added the code below and built it. Created a new
form and added the revised control to it.
The two properties do not appear in the properties list - great.
However, AutoScroll does not appear in the code listing, why not?
Also, AutoScrollMargin does appear in the code listing, I thought
EditorBrowsable would supress it

<Browsable(False)> _
Public Overrides Property AutoScroll() As Boolean
Get
Return MyBase.AutoScroll
End Get
Set(ByVal value As Boolean)
MyBase.AutoScroll = value
End Set
End Property

<Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
Public Shadows Property AutoScrollMargin() As Size
Get
Return MyBase.AutoScrollMargin
End Get
Set(ByVal value As Size)
MyBase.AutoScrollMargin = value
End Set
End Property


Nov 21 '05 #14

P: n/a

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:eM**************@TK2MSFTNGP14.phx.gbl...
Just Me,
What specifically do you mean "appear in the code listing"?

Do you mean Intellisense or the

I meant this."Windows Forms Generated Code" region? I was hoping to stop the code generation/apperance. Doesn't DefaultValue
only effect the value assigned in the code generated?


EditorBrowsable controls Intellisense.

DefaultValue controls the "Windows Forms Generated Code" region.

It might be that Intellisense is not as intelligent as the Property Grid
when it comes to Shadows & properties.

Hope this helps
Jay

" Just Me" <gr****@a-znet.com> wrote in message
news:eO**************@TK2MSFTNGP14.phx.gbl...
Always a complication. I added the code below and built it. Created a new
form and added the revised control to it.
The two properties do not appear in the properties list - great.
However, AutoScroll does not appear in the code listing, why not?
Also, AutoScrollMargin does appear in the code listing, I thought
EditorBrowsable would supress it

<Browsable(False)> _
Public Overrides Property AutoScroll() As Boolean
Get
Return MyBase.AutoScroll
End Get
Set(ByVal value As Boolean)
MyBase.AutoScroll = value
End Set
End Property

<Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
Public Shadows Property AutoScrollMargin() As Size
Get
Return MyBase.AutoScrollMargin
End Get
Set(ByVal value As Size)
MyBase.AutoScrollMargin = value
End Set
End Property


Nov 21 '05 #15

P: n/a
Just Me,
I meant this.
"Windows Forms Generated Code" region? I was hoping to stop the code generation/appearance. Doesn't DefaultValue
only effect the value assigned in the code generated?


What is "this"? If you mean "Windows Forms Generated Code" region, then yes.
It effects the value assigned in the code generated.

Define exactly what you mean "stop the code generation/apperance" that is
different from "value assigned in the code generated". Remember we are
talking properties, not fields here.

You can use either ShouldSerialize* or DefaultValue to control if the
"setting the default" code is added to the "Windows Forms Generated Code"
region or not.

http://msdn.microsoft.com/library/de...setmethods.asp

Something like:
Private Sub ResetAutoScrollMargin ()
... set AutoScrollMargin to "default" value
End Sub

Private Function ShouldSerializeAutoScrollMargin () As Boolean
... return True if you want value in "Windows Forms Generated Code"
region
End Function

Remember if you never change the value from the default, then no code is
added... Also remember that DefaultValue is a hint to the designer, you
still need to set the property's default value in the object's constructor.

You may want to ask in one of the Windows Forms newsgroups to double check,
some properties (such as Size) have other "special" properties & methods
(such as DefaultSize) that control their default value, I don't remember if
AutoScrollMargin has "special" related properties & methods.

Hope this helps
Jay


" Just Me" <gr****@a-znet.com> wrote in message
news:Od**************@TK2MSFTNGP14.phx.gbl...
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:eM**************@TK2MSFTNGP14.phx.gbl...
Just Me,
What specifically do you mean "appear in the code listing"?

Do you mean Intellisense or the

I meant this.
"Windows Forms Generated Code" region?

I was hoping to stop the code generation/apperance. Doesn't DefaultValue
only effect the value assigned in the code generated?


EditorBrowsable controls Intellisense.

DefaultValue controls the "Windows Forms Generated Code" region.

It might be that Intellisense is not as intelligent as the Property Grid
when it comes to Shadows & properties.

Hope this helps
Jay

" Just Me" <gr****@a-znet.com> wrote in message
news:eO**************@TK2MSFTNGP14.phx.gbl...
Always a complication. I added the code below and built it. Created a
new form and added the revised control to it.
The two properties do not appear in the properties list - great.
However, AutoScroll does not appear in the code listing, why not?
Also, AutoScrollMargin does appear in the code listing, I thought
EditorBrowsable would supress it

<Browsable(False)> _
Public Overrides Property AutoScroll() As Boolean
Get
Return MyBase.AutoScroll
End Get
Set(ByVal value As Boolean)
MyBase.AutoScroll = value
End Set
End Property

<Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
Public Shadows Property AutoScrollMargin() As Size
Get
Return MyBase.AutoScrollMargin
End Get
Set(ByVal value As Size)
MyBase.AutoScrollMargin = value
End Set
End Property



Nov 21 '05 #16

P: n/a
Just Me,
I meant this.
"Windows Forms Generated Code" region? I was hoping to stop the code generation/appearance. Doesn't DefaultValue
only effect the value assigned in the code generated?


What is "this"? If you mean "Windows Forms Generated Code" region, then yes.
It effects the value assigned in the code generated.

Define exactly what you mean "stop the code generation/apperance" that is
different from "value assigned in the code generated". Remember we are
talking properties, not fields here.

You can use either ShouldSerialize* or DefaultValue to control if the
"setting the default" code is added to the "Windows Forms Generated Code"
region or not.

http://msdn.microsoft.com/library/de...setmethods.asp

Something like:
Private Sub ResetAutoScrollMargin ()
... set AutoScrollMargin to "default" value
End Sub

Private Function ShouldSerializeAutoScrollMargin () As Boolean
... return True if you want value in "Windows Forms Generated Code"
region
End Function

Remember if you never change the value from the default, then no code is
added... Also remember that DefaultValue is a hint to the designer, you
still need to set the property's default value in the object's constructor.

You may want to ask in one of the Windows Forms newsgroups to double check,
some properties (such as Size) have other "special" properties & methods
(such as DefaultSize) that control their default value, I don't remember if
AutoScrollMargin has "special" related properties & methods.

Hope this helps
Jay


" Just Me" <gr****@a-znet.com> wrote in message
news:Od**************@TK2MSFTNGP14.phx.gbl...
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:eM**************@TK2MSFTNGP14.phx.gbl...
Just Me,
What specifically do you mean "appear in the code listing"?

Do you mean Intellisense or the

I meant this.
"Windows Forms Generated Code" region?

I was hoping to stop the code generation/apperance. Doesn't DefaultValue
only effect the value assigned in the code generated?


EditorBrowsable controls Intellisense.

DefaultValue controls the "Windows Forms Generated Code" region.

It might be that Intellisense is not as intelligent as the Property Grid
when it comes to Shadows & properties.

Hope this helps
Jay

" Just Me" <gr****@a-znet.com> wrote in message
news:eO**************@TK2MSFTNGP14.phx.gbl...
Always a complication. I added the code below and built it. Created a
new form and added the revised control to it.
The two properties do not appear in the properties list - great.
However, AutoScroll does not appear in the code listing, why not?
Also, AutoScrollMargin does appear in the code listing, I thought
EditorBrowsable would supress it

<Browsable(False)> _
Public Overrides Property AutoScroll() As Boolean
Get
Return MyBase.AutoScroll
End Get
Set(ByVal value As Boolean)
MyBase.AutoScroll = value
End Set
End Property

<Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
Public Shadows Property AutoScrollMargin() As Size
Get
Return MyBase.AutoScrollMargin
End Get
Set(ByVal value As Size)
MyBase.AutoScrollMargin = value
End Set
End Property



Nov 21 '05 #17

P: n/a
> Define exactly what you mean "stop the code generation/apperance" that is
different from "value assigned in the code generated". Remember we are
talking properties, not fields here.

Simple. The Designer generates code like the following:
Me.ControlEditor1.AutoScrollMargin = New System.Drawing.Size(0, 0)
Me.ControlEditor1.AutoScrollMinSize = New System.Drawing.Size(0, 0)

I like to surpress that generation. I have a couple of situations when it is
more important that this example.

Nov 21 '05 #18

P: n/a
> Define exactly what you mean "stop the code generation/apperance" that is
different from "value assigned in the code generated". Remember we are
talking properties, not fields here.

Simple. The Designer generates code like the following:
Me.ControlEditor1.AutoScrollMargin = New System.Drawing.Size(0, 0)
Me.ControlEditor1.AutoScrollMinSize = New System.Drawing.Size(0, 0)

I like to surpress that generation. I have a couple of situations when it is
more important that this example.

Nov 21 '05 #19

P: n/a
I think I found it:
<Browsable(False),DesignerSerializationVisibility( DesignerSerializationVisibility.Hidden)>

I need to test more but I thought I'd pass it on.

Thanks a lot

" Just Me" <gr****@a-znet.com> wrote in message
news:u%****************@TK2MSFTNGP14.phx.gbl...
Define exactly what you mean "stop the code generation/apperance" that is
different from "value assigned in the code generated". Remember we are
talking properties, not fields here.

Simple. The Designer generates code like the following:
Me.ControlEditor1.AutoScrollMargin = New System.Drawing.Size(0, 0)
Me.ControlEditor1.AutoScrollMinSize = New System.Drawing.Size(0, 0)

I like to surpress that generation. I have a couple of situations when it
is more important that this example.

Nov 21 '05 #20

P: n/a
I think I found it:
<Browsable(False),DesignerSerializationVisibility( DesignerSerializationVisibility.Hidden)>

I need to test more but I thought I'd pass it on.

Thanks a lot

" Just Me" <gr****@a-znet.com> wrote in message
news:u%****************@TK2MSFTNGP14.phx.gbl...
Define exactly what you mean "stop the code generation/apperance" that is
different from "value assigned in the code generated". Remember we are
talking properties, not fields here.

Simple. The Designer generates code like the following:
Me.ControlEditor1.AutoScrollMargin = New System.Drawing.Size(0, 0)
Me.ControlEditor1.AutoScrollMinSize = New System.Drawing.Size(0, 0)

I like to surpress that generation. I have a couple of situations when it
is more important that this example.

Nov 21 '05 #21

P: n/a
I tried the Shadows with Browsable False and it still shows up in the
Properties Window at Design time as well as in the Intell..sense.

"Jay B. Harlow [MVP - Outlook]" wrote:
Dennis,
If you want to "override" the *attributes* of a not overridable property.

You can Shadow the property.
<Browsable(False)> _
Public Shadows Property AutoScroll() As Boolean
Get
Return MyBase.AutoScroll
End Get
Set(ByVal Value As Boolean)
MyBase.AutoScroll = Value
End Set
End Property


Note: Shadowing a property to change the attributes is one of the few times
when you need to "design" with Shadows. Otherwise Shadows should be reserved
for version control...

However as Herfried suggests, Control.AutoScroll is overridable in VB.NET
2003.

Hope this helps
Jay

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
AutoScroll cannot be overridden!

"Herfried K. Wagner [MVP]" wrote:
" Just Me" <gr****@a-znet.com> schrieb:
> Am I missing something?
> Where would I place <Browsable(False)>
> The AutoScroll property comes with the UserControl.
> I don't generate it.

Untested:

\\\
<Browsable(False)> _
Public Overrides Property AutoScroll() As Boolean
Get
Return MyBase.AutoScroll
End Get
Set(ByVal Value As Boolean)
MyBase.AutoScroll = Value
End Set
End Property
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #22

P: n/a
Jay, as usual, you are correct. I was using Private. When I changed it to
Public, the properties did NOT appear in the Properties Window. Thanks.

"Jay B. Harlow [MVP - Outlook]" wrote:
Dennis,
If you want to "override" the *attributes* of a not overridable property.

You can Shadow the property.
<Browsable(False)> _
Public Shadows Property AutoScroll() As Boolean
Get
Return MyBase.AutoScroll
End Get
Set(ByVal Value As Boolean)
MyBase.AutoScroll = Value
End Set
End Property


Note: Shadowing a property to change the attributes is one of the few times
when you need to "design" with Shadows. Otherwise Shadows should be reserved
for version control...

However as Herfried suggests, Control.AutoScroll is overridable in VB.NET
2003.

Hope this helps
Jay

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
AutoScroll cannot be overridden!

"Herfried K. Wagner [MVP]" wrote:
" Just Me" <gr****@a-znet.com> schrieb:
> Am I missing something?
> Where would I place <Browsable(False)>
> The AutoScroll property comes with the UserControl.
> I don't generate it.

Untested:

\\\
<Browsable(False)> _
Public Overrides Property AutoScroll() As Boolean
Get
Return MyBase.AutoScroll
End Get
Set(ByVal Value As Boolean)
MyBase.AutoScroll = Value
End Set
End Property
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #23

P: n/a
Just one more question on Shadows (I know you don't like them) but If I
shadow a property and do NOT call MyBase.property in the sub, then I assume
MyBase.Property procedure will not be executed...is this correct?

"Jay B. Harlow [MVP - Outlook]" wrote:
Dennis,
If you want to "override" the *attributes* of a not overridable property.

You can Shadow the property.
<Browsable(False)> _
Public Shadows Property AutoScroll() As Boolean
Get
Return MyBase.AutoScroll
End Get
Set(ByVal Value As Boolean)
MyBase.AutoScroll = Value
End Set
End Property


Note: Shadowing a property to change the attributes is one of the few times
when you need to "design" with Shadows. Otherwise Shadows should be reserved
for version control...

However as Herfried suggests, Control.AutoScroll is overridable in VB.NET
2003.

Hope this helps
Jay

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
AutoScroll cannot be overridden!

"Herfried K. Wagner [MVP]" wrote:
" Just Me" <gr****@a-znet.com> schrieb:
> Am I missing something?
> Where would I place <Browsable(False)>
> The AutoScroll property comes with the UserControl.
> I don't generate it.

Untested:

\\\
<Browsable(False)> _
Public Overrides Property AutoScroll() As Boolean
Get
Return MyBase.AutoScroll
End Get
Set(ByVal Value As Boolean)
MyBase.AutoScroll = Value
End Set
End Property
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #24

P: n/a
Jay, another question: If I read your reply correctly, if I shadow
AutoScroll property and set the designer and browsable to False, and If I
want the AutoScroll to be False, then I must set it in the "New" procedure?
Is this correct?

"Jay B. Harlow [MVP - Outlook]" wrote:
Just Me,
I meant this.
"Windows Forms Generated Code" region?

I was hoping to stop the code generation/appearance. Doesn't DefaultValue
only effect the value assigned in the code generated?


What is "this"? If you mean "Windows Forms Generated Code" region, then yes.
It effects the value assigned in the code generated.

Define exactly what you mean "stop the code generation/apperance" that is
different from "value assigned in the code generated". Remember we are
talking properties, not fields here.

You can use either ShouldSerialize* or DefaultValue to control if the
"setting the default" code is added to the "Windows Forms Generated Code"
region or not.

http://msdn.microsoft.com/library/de...setmethods.asp

Something like:
Private Sub ResetAutoScrollMargin ()
... set AutoScrollMargin to "default" value
End Sub

Private Function ShouldSerializeAutoScrollMargin () As Boolean
... return True if you want value in "Windows Forms Generated Code"
region
End Function

Remember if you never change the value from the default, then no code is
added... Also remember that DefaultValue is a hint to the designer, you
still need to set the property's default value in the object's constructor.

You may want to ask in one of the Windows Forms newsgroups to double check,
some properties (such as Size) have other "special" properties & methods
(such as DefaultSize) that control their default value, I don't remember if
AutoScrollMargin has "special" related properties & methods.

Hope this helps
Jay


" Just Me" <gr****@a-znet.com> wrote in message
news:Od**************@TK2MSFTNGP14.phx.gbl...

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:eM**************@TK2MSFTNGP14.phx.gbl...
Just Me,
What specifically do you mean "appear in the code listing"?

Do you mean Intellisense or the

I meant this.
"Windows Forms Generated Code" region?

I was hoping to stop the code generation/apperance. Doesn't DefaultValue
only effect the value assigned in the code generated?


EditorBrowsable controls Intellisense.

DefaultValue controls the "Windows Forms Generated Code" region.

It might be that Intellisense is not as intelligent as the Property Grid
when it comes to Shadows & properties.

Hope this helps
Jay

" Just Me" <gr****@a-znet.com> wrote in message
news:eO**************@TK2MSFTNGP14.phx.gbl...
Always a complication. I added the code below and built it. Created a
new form and added the revised control to it.
The two properties do not appear in the properties list - great.
However, AutoScroll does not appear in the code listing, why not?
Also, AutoScrollMargin does appear in the code listing, I thought
EditorBrowsable would supress it

<Browsable(False)> _
Public Overrides Property AutoScroll() As Boolean
Get
Return MyBase.AutoScroll
End Get
Set(ByVal value As Boolean)
MyBase.AutoScroll = value
End Set
End Property

<Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
Public Shadows Property AutoScrollMargin() As Size
Get
Return MyBase.AutoScrollMargin
End Get
Set(ByVal value As Size)
MyBase.AutoScrollMargin = value
End Set
End Property



Nov 21 '05 #25

P: n/a
Dennis,
Just one more question on Shadows (I know you don't like them) Its not that I don't like them per se, they are a very powerful & useful
tool, I use them when they are needed. However you need to use extreme
caution when using them, hence my cautioning others!
then I assume
MyBase.Property procedure will not be executed Ah! There's the rub!

Sometimes it might be, sometimes not.

Remember that Shadows is anti-polymorphism, hence my

Try the following:

Public Class Shadow

Public Shadows Function ToString() As String
Return "This is a shadow!"
End Function

End Class

Dim s As New Shadow
Dim o As Object = s

Debug.WriteLine(s, "1")
Debug.WriteLine(o, "2")
Debug.WriteLine(s.ToString(), "3")
Debug.WriteLine(o.ToString(), "4")

Polymorphism states that all four lines should print "This is a shadow!",
however the Shadows keyword only allows line 3 to say it. The other 3 lines
are calling the Object.ToString & not Shadow.ToString

If you change ToString to be Overrides, then "This is a shadow!" will print
on all four lines. As Shadow.ToString is overriding (replacing)
Object.ToString.

Public Overrides Function ToString() As String
Calling MyBase.AutoScroll in the sample, simply ensures that AutoScroll
behaves consistently despite the Shadow. If you used your own variable,
calling ScrollableControl.AutoScroll

Consider the following AutoScroll that does its own thing with Shadows.

Public Class MyControl
Inherits UserControl

Private m_autoScroll As Boolean

<Browsable(False)> _
Public Shadows Property AutoScroll() As Boolean
Get
Return m_autoScroll
End Get
Set(ByVal value As Boolean)
m_autoScroll = value
End Set
End Property

...

End Class

Consider the following in a form someplace:

For Each child As Control in My.Controls
If TypeOf child Is ScrollableControl Then
Dim sc As ScrollableControl = DirectCast(child,
ScrollableControl)
sc.AutoScroll = False
End If
Next

The MyControl.m_autoScroll value will not be updated as MyControl shadows
ScrollableControl.AutoScroll, calling AutoScroll via the ScrollableControl
variable will call ScrollableControl.AutoScroll & not
MyControl.AutoScroll...

Hope this helps
Jay
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com... Just one more question on Shadows (I know you don't like them) but If I
shadow a property and do NOT call MyBase.property in the sub, then I
assume
MyBase.Property procedure will not be executed...is this correct?

"Jay B. Harlow [MVP - Outlook]" wrote:
Dennis,
If you want to "override" the *attributes* of a not overridable property.

You can Shadow the property.
>> <Browsable(False)> _
>> Public Shadows Property AutoScroll() As Boolean
>> Get
>> Return MyBase.AutoScroll
>> End Get
>> Set(ByVal Value As Boolean)
>> MyBase.AutoScroll = Value
>> End Set
>> End Property


Note: Shadowing a property to change the attributes is one of the few
times
when you need to "design" with Shadows. Otherwise Shadows should be
reserved
for version control...

However as Herfried suggests, Control.AutoScroll is overridable in VB.NET
2003.

Hope this helps
Jay

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
> AutoScroll cannot be overridden!
>
> "Herfried K. Wagner [MVP]" wrote:
>
>> " Just Me" <gr****@a-znet.com> schrieb:
>> > Am I missing something?
>> > Where would I place <Browsable(False)>
>> > The AutoScroll property comes with the UserControl.
>> > I don't generate it.
>>
>> Untested:
>>
>> \\\
>> <Browsable(False)> _
>> Public Overrides Property AutoScroll() As Boolean
>> Get
>> Return MyBase.AutoScroll
>> End Get
>> Set(ByVal Value As Boolean)
>> MyBase.AutoScroll = Value
>> End Set
>> End Property
>> ///
>>
>> --
>> M S Herfried K. Wagner
>> M V P <URL:http://dotnet.mvps.org/>
>> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
>>


Nov 21 '05 #26

P: n/a
Thanks for explaination. I will restrict my use of Shadows code that won't
be used by anyone else unless I have to. I wonder why M'soft didn't allow
overridding properties such as autoscroll. Anyway, thanks again.

"Jay B. Harlow [MVP - Outlook]" wrote:
Dennis,
Just one more question on Shadows (I know you don't like them)

Its not that I don't like them per se, they are a very powerful & useful
tool, I use them when they are needed. However you need to use extreme
caution when using them, hence my cautioning others!
then I assume
MyBase.Property procedure will not be executed

Ah! There's the rub!

Sometimes it might be, sometimes not.

Remember that Shadows is anti-polymorphism, hence my

Try the following:

Public Class Shadow

Public Shadows Function ToString() As String
Return "This is a shadow!"
End Function

End Class

Dim s As New Shadow
Dim o As Object = s

Debug.WriteLine(s, "1")
Debug.WriteLine(o, "2")
Debug.WriteLine(s.ToString(), "3")
Debug.WriteLine(o.ToString(), "4")

Polymorphism states that all four lines should print "This is a shadow!",
however the Shadows keyword only allows line 3 to say it. The other 3 lines
are calling the Object.ToString & not Shadow.ToString

If you change ToString to be Overrides, then "This is a shadow!" will print
on all four lines. As Shadow.ToString is overriding (replacing)
Object.ToString.

Public Overrides Function ToString() As String
Calling MyBase.AutoScroll in the sample, simply ensures that AutoScroll
behaves consistently despite the Shadow. If you used your own variable,
calling ScrollableControl.AutoScroll

Consider the following AutoScroll that does its own thing with Shadows.

Public Class MyControl
Inherits UserControl

Private m_autoScroll As Boolean

<Browsable(False)> _
Public Shadows Property AutoScroll() As Boolean
Get
Return m_autoScroll
End Get
Set(ByVal value As Boolean)
m_autoScroll = value
End Set
End Property

...

End Class

Consider the following in a form someplace:

For Each child As Control in My.Controls
If TypeOf child Is ScrollableControl Then
Dim sc As ScrollableControl = DirectCast(child,
ScrollableControl)
sc.AutoScroll = False
End If
Next

The MyControl.m_autoScroll value will not be updated as MyControl shadows
ScrollableControl.AutoScroll, calling AutoScroll via the ScrollableControl
variable will call ScrollableControl.AutoScroll & not
MyControl.AutoScroll...

Hope this helps
Jay
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
Just one more question on Shadows (I know you don't like them) but If I
shadow a property and do NOT call MyBase.property in the sub, then I
assume
MyBase.Property procedure will not be executed...is this correct?

"Jay B. Harlow [MVP - Outlook]" wrote:
Dennis,
If you want to "override" the *attributes* of a not overridable property.

You can Shadow the property.

>> <Browsable(False)> _
>> Public Shadows Property AutoScroll() As Boolean
>> Get
>> Return MyBase.AutoScroll
>> End Get
>> Set(ByVal Value As Boolean)
>> MyBase.AutoScroll = Value
>> End Set
>> End Property

Note: Shadowing a property to change the attributes is one of the few
times
when you need to "design" with Shadows. Otherwise Shadows should be
reserved
for version control...

However as Herfried suggests, Control.AutoScroll is overridable in VB.NET
2003.

Hope this helps
Jay

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
> AutoScroll cannot be overridden!
>
> "Herfried K. Wagner [MVP]" wrote:
>
>> " Just Me" <gr****@a-znet.com> schrieb:
>> > Am I missing something?
>> > Where would I place <Browsable(False)>
>> > The AutoScroll property comes with the UserControl.
>> > I don't generate it.
>>
>> Untested:
>>
>> \\\
>> <Browsable(False)> _
>> Public Overrides Property AutoScroll() As Boolean
>> Get
>> Return MyBase.AutoScroll
>> End Get
>> Set(ByVal Value As Boolean)
>> MyBase.AutoScroll = Value
>> End Set
>> End Property
>> ///
>>
>> --
>> M S Herfried K. Wagner
>> M V P <URL:http://dotnet.mvps.org/>
>> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
>>


Nov 21 '05 #27

P: n/a
Dennis,
AutoScroll is overridable! we were just using it as the original poster
asked about it.

Hope this helps
Jay

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
Thanks for explaination. I will restrict my use of Shadows code that
won't
be used by anyone else unless I have to. I wonder why M'soft didn't allow
overridding properties such as autoscroll. Anyway, thanks again.

"Jay B. Harlow [MVP - Outlook]" wrote:
Dennis,
> Just one more question on Shadows (I know you don't like them)

Its not that I don't like them per se, they are a very powerful & useful
tool, I use them when they are needed. However you need to use extreme
caution when using them, hence my cautioning others!
> then I assume
> MyBase.Property procedure will not be executed

Ah! There's the rub!

Sometimes it might be, sometimes not.

Remember that Shadows is anti-polymorphism, hence my

Try the following:

Public Class Shadow

Public Shadows Function ToString() As String
Return "This is a shadow!"
End Function

End Class

Dim s As New Shadow
Dim o As Object = s

Debug.WriteLine(s, "1")
Debug.WriteLine(o, "2")
Debug.WriteLine(s.ToString(), "3")
Debug.WriteLine(o.ToString(), "4")

Polymorphism states that all four lines should print "This is a shadow!",
however the Shadows keyword only allows line 3 to say it. The other 3
lines
are calling the Object.ToString & not Shadow.ToString

If you change ToString to be Overrides, then "This is a shadow!" will
print
on all four lines. As Shadow.ToString is overriding (replacing)
Object.ToString.

Public Overrides Function ToString() As String
Calling MyBase.AutoScroll in the sample, simply ensures that AutoScroll
behaves consistently despite the Shadow. If you used your own variable,
calling ScrollableControl.AutoScroll

Consider the following AutoScroll that does its own thing with Shadows.

Public Class MyControl
Inherits UserControl

Private m_autoScroll As Boolean

<Browsable(False)> _
Public Shadows Property AutoScroll() As Boolean
Get
Return m_autoScroll
End Get
Set(ByVal value As Boolean)
m_autoScroll = value
End Set
End Property

...

End Class

Consider the following in a form someplace:

For Each child As Control in My.Controls
If TypeOf child Is ScrollableControl Then
Dim sc As ScrollableControl = DirectCast(child,
ScrollableControl)
sc.AutoScroll = False
End If
Next

The MyControl.m_autoScroll value will not be updated as MyControl shadows
ScrollableControl.AutoScroll, calling AutoScroll via the
ScrollableControl
variable will call ScrollableControl.AutoScroll & not
MyControl.AutoScroll...

Hope this helps
Jay
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
> Just one more question on Shadows (I know you don't like them) but If I
> shadow a property and do NOT call MyBase.property in the sub, then I
> assume
> MyBase.Property procedure will not be executed...is this correct?
>
> "Jay B. Harlow [MVP - Outlook]" wrote:
>
>> Dennis,
>> If you want to "override" the *attributes* of a not overridable
>> property.
>>
>> You can Shadow the property.
>>
>> >> <Browsable(False)> _
>> >> Public Shadows Property AutoScroll() As Boolean
>> >> Get
>> >> Return MyBase.AutoScroll
>> >> End Get
>> >> Set(ByVal Value As Boolean)
>> >> MyBase.AutoScroll = Value
>> >> End Set
>> >> End Property
>>
>> Note: Shadowing a property to change the attributes is one of the few
>> times
>> when you need to "design" with Shadows. Otherwise Shadows should be
>> reserved
>> for version control...
>>
>> However as Herfried suggests, Control.AutoScroll is overridable in
>> VB.NET
>> 2003.
>>
>> Hope this helps
>> Jay
>>
>> "Dennis" <De****@discussions.microsoft.com> wrote in message
>> news:85**********************************@microsof t.com...
>> > AutoScroll cannot be overridden!
>> >
>> > "Herfried K. Wagner [MVP]" wrote:
>> >
>> >> " Just Me" <gr****@a-znet.com> schrieb:
>> >> > Am I missing something?
>> >> > Where would I place <Browsable(False)>
>> >> > The AutoScroll property comes with the UserControl.
>> >> > I don't generate it.
>> >>
>> >> Untested:
>> >>
>> >> \\\
>> >> <Browsable(False)> _
>> >> Public Overrides Property AutoScroll() As Boolean
>> >> Get
>> >> Return MyBase.AutoScroll
>> >> End Get
>> >> Set(ByVal Value As Boolean)
>> >> MyBase.AutoScroll = Value
>> >> End Set
>> >> End Property
>> >> ///
>> >>
>> >> --
>> >> M S Herfried K. Wagner
>> >> M V P <URL:http://dotnet.mvps.org/>
>> >> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
>> >>
>>
>>
>>


Nov 21 '05 #28

This discussion thread is closed

Replies have been disabled for this discussion.