473,320 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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
27 1813
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
" 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
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
" 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
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
"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
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

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
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

"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
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
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

"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

"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
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
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
> 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
> 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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Job Lot | last post by:
I have added a ProgressBar control to StatusBar control and created a custom property as below, to show the properties of the ProgressBar in Property Window of StatusBar. <Browsable(True)> _...
2
by: Balamurukan | last post by:
How to retrive property values from our own property window
1
by: Steven.Xu | last post by:
Hi, everyone. I am writting an user control. There has some properties on it. At the design time, the properties will disply on the property windows and user could change it's value after selected...
7
by: Baski | last post by:
Base class: class AssetBase { string _clli; public string CLLI { get
2
by: Rob Richardson | last post by:
Greetings! I just developed a little control I've wanted for ages. It links a textbox and a label into a single control. At first, I gave it a property named LabelText and another named...
0
by: Stephen Carson | last post by:
I cannot see a browsable property I have added in the Properties Window. Using C++ in Visual Studio .NET 2003 I have added a property to my managed class: public:
1
by: Eldon Ferran de Pol | last post by:
Hi all I've got a custom control that has several image based properties I wan't each of these properties to use the standard .Net dialog box for selecting a URL that appears when setting the...
6
by: Altman | last post by:
I would like to use an indexed property to access my private array of user controls. If I don't use an indexed property, the property will show up in my Properties Window during development. Is...
3
by: Meelis | last post by:
Hi Can one property have different types? For example, i need to property type to be dependend on second property. Pirvate MyValue as Object Private MyType as Integer Public Property...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.