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 27 1775
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
" 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/>
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
" 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/>
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/>
"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/>
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/> 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?
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?
"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
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
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
"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
"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
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
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
> 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.
> 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.
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.
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.
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/>
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/>
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/>
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
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/> >>
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/> >>
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/> >> >> >> >> >> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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)> _...
|
by: Balamurukan |
last post by:
How to retrive property values from our own property window
|
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...
|
by: Baski |
last post by:
Base class:
class AssetBase
{
string _clli;
public string CLLI
{
get
|
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...
|
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:
|
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...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |