|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Label Autosize Property... Possible bug??Public Class LabelEx Inherits System.Windows.Forms.Label Sub New() MyBase.New() Me.ForeColor = Color.Black Me.AutoSize = False Me.Height = 16 End Sub <System.ComponentModel.DefaultValue(False)> _ Public Overrides Property AutoSize() As Boolean Get Return MyBase.AutoSize End Get Set(ByVal value As Boolean) MyBase.AutoSize = value End Set End Property End Class The problem is that Autosize Property remains always as true when I go to design mode and put my LabelEx from the ToolBox to the form. Looking at the designer file, I can see as every property I have set to all my other extended controls is correct, except from autosize for labels... Any idea??? I've been unable to find this anywhere, and it looks like a bug, doesn't it? By the way, this code works properly in VS 2003, and although the default in 2003 is Autosize=false, if I put it to true, it works with no problem, the designer sets the value I've said... Jordi,
I noticed that the other day, it feels like a bug to me, as VS is "breaking" the contract that System.ComponentModel.DefaultValue states. I will see what I can find. -- Show quoteHide quoteHope this helps Jay B. Harlow [MVP - Outlook] ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "Jordi Rico" <jordir***@gmail.com> wrote in message news:1150454592.642448.18680@u72g2000cwu.googlegroups.com... | Hi, I've made the next inherited class in Visual Studio 2005: | | Public Class LabelEx | Inherits System.Windows.Forms.Label | | Sub New() | MyBase.New() | Me.ForeColor = Color.Black | Me.AutoSize = False | Me.Height = 16 | End Sub | | <System.ComponentModel.DefaultValue(False)> _ | Public Overrides Property AutoSize() As Boolean | Get | Return MyBase.AutoSize | End Get | Set(ByVal value As Boolean) | MyBase.AutoSize = value | End Set | End Property | End Class | | The problem is that Autosize Property remains always as true when I go | to design mode and put my LabelEx from the ToolBox to the form. Looking | at the designer file, I can see as every property I have set to all my | other extended controls is correct, except from autosize for labels... | Any idea??? I've been unable to find this anywhere, and it looks like a | bug, doesn't it? By the way, this code works properly in VS 2003, and | although the default in 2003 is Autosize=false, if I put it to true, it | works with no problem, the designer sets the value I've said... | Hi Jay,
if you find something please tell me, I'm looking everywhere and cannot find anything clear... Thank you Jay B. Harlow [MVP - Outlook] ha escrito: Show quoteHide quote > Jordi, > I noticed that the other day, it feels like a bug to me, as VS is "breaking" > the contract that System.ComponentModel.DefaultValue states. > > I will see what I can find. > > -- > Hope this helps > Jay B. Harlow [MVP - Outlook] > .NET Application Architect, Enthusiast, & Evangelist > T.S. Bradley - http://www.tsbradley.net > > > "Jordi Rico" <jordir***@gmail.com> wrote in message > news:1150454592.642448.18680@u72g2000cwu.googlegroups.com... > | Hi, I've made the next inherited class in Visual Studio 2005: > | > | Public Class LabelEx > | Inherits System.Windows.Forms.Label > | > | Sub New() > | MyBase.New() > | Me.ForeColor = Color.Black > | Me.AutoSize = False > | Me.Height = 16 > | End Sub > | > | <System.ComponentModel.DefaultValue(False)> _ > | Public Overrides Property AutoSize() As Boolean > | Get > | Return MyBase.AutoSize > | End Get > | Set(ByVal value As Boolean) > | MyBase.AutoSize = value > | End Set > | End Property > | End Class > | > | The problem is that Autosize Property remains always as true when I go > | to design mode and put my LabelEx from the ToolBox to the form. Looking > | at the designer file, I can see as every property I have set to all my > | other extended controls is correct, except from autosize for labels... > | Any idea??? I've been unable to find this anywhere, and it looks like a > | bug, doesn't it? By the way, this code works properly in VS 2003, and > | although the default in 2003 is Autosize=false, if I put it to true, it > | works with no problem, the designer sets the value I've said... > | Wouldn't you have to in your constructor set MyBase.AutoSize = False?
I thought the DefaultValue attribute just determines whether or not design time code is generated when the property is the default value. When the property is already the default value, it doesn't bother generating the line of code, and the property value is not bold in the properties window. When it's anything other then the default, only then does it bother generating a line for it, and then it looks bold in the properties window so it's easier to tell you've modified it. Show quoteHide quote "Jordi Rico" <jordir***@gmail.com> wrote in message news:1150454592.642448.18680@u72g2000cwu.googlegroups.com... > Hi, I've made the next inherited class in Visual Studio 2005: > > Public Class LabelEx > Inherits System.Windows.Forms.Label > > Sub New() > MyBase.New() > Me.ForeColor = Color.Black > Me.AutoSize = False > Me.Height = 16 > End Sub > > <System.ComponentModel.DefaultValue(False)> _ > Public Overrides Property AutoSize() As Boolean > Get > Return MyBase.AutoSize > End Get > Set(ByVal value As Boolean) > MyBase.AutoSize = value > End Set > End Property > End Class > > The problem is that Autosize Property remains always as true when I go > to design mode and put my LabelEx from the ToolBox to the form. Looking > at the designer file, I can see as every property I have set to all my > other extended controls is correct, except from autosize for labels... > Any idea??? I've been unable to find this anywhere, and it looks like a > bug, doesn't it? By the way, this code works properly in VS 2003, and > although the default in 2003 is Autosize=false, if I put it to true, it > works with no problem, the designer sets the value I've said... > Marina,
He has Me.AutoSize = False in his constructor. His overridden Property then does a MyBase.AutoSize = false. Net effect is the same thing. | I thought the DefaultValue attribute just determines whether or not design Ah! There's the rub! or should I say there's the bug!| time code is generated when the property is the default value. The DefaultValueAttribute determines whether or not design time code is generated. The constructor determines the runtime code. Well apparently in the case of Label, the new .NET 2.0 layout manager decides to ignore both & applies AutoSize = True to the control... A fellow MVP uses the following code as a workaround: Public Class LabelEx Inherits System.Windows.Forms.Label Private m_inited As Boolean Sub New() MyBase.New() Me.ForeColor = Color.Black Me.AutoSize = False Me.Height = 16 End Sub Protected Overrides Sub InitLayout() MyBase.InitLayout() m_inited = True End Sub <System.ComponentModel.DefaultValue(False)> _ Public Overrides Property AutoSize() As Boolean Get Return MyBase.AutoSize End Get Set(ByVal value As Boolean) If Me.DesignMode AndAlso Not m_inited Then Return MyBase.AutoSize = value End Set End Property End Class -- Show quoteHide quoteHope this helps Jay B. Harlow [MVP - Outlook] ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "Marina Levit [MVP]" <someone@nospam.com> wrote in message news:OHw7k0VkGHA.3304@TK2MSFTNGP03.phx.gbl... | Wouldn't you have to in your constructor set MyBase.AutoSize = False? | | I thought the DefaultValue attribute just determines whether or not design | time code is generated when the property is the default value. When the | property is already the default value, it doesn't bother generating the line | of code, and the property value is not bold in the properties window. When | it's anything other then the default, only then does it bother generating a | line for it, and then it looks bold in the properties window so it's easier | to tell you've modified it. | | "Jordi Rico" <jordir***@gmail.com> wrote in message | news:1150454592.642448.18680@u72g2000cwu.googlegroups.com... | > Hi, I've made the next inherited class in Visual Studio 2005: | > | > Public Class LabelEx | > Inherits System.Windows.Forms.Label | > | > Sub New() | > MyBase.New() | > Me.ForeColor = Color.Black | > Me.AutoSize = False | > Me.Height = 16 | > End Sub | > | > <System.ComponentModel.DefaultValue(False)> _ | > Public Overrides Property AutoSize() As Boolean | > Get | > Return MyBase.AutoSize | > End Get | > Set(ByVal value As Boolean) | > MyBase.AutoSize = value | > End Set | > End Property | > End Class | > | > The problem is that Autosize Property remains always as true when I go | > to design mode and put my LabelEx from the ToolBox to the form. Looking | > at the designer file, I can see as every property I have set to all my | > other extended controls is correct, except from autosize for labels... | > Any idea??? I've been unable to find this anywhere, and it looks like a | > bug, doesn't it? By the way, this code works properly in VS 2003, and | > although the default in 2003 is Autosize=false, if I put it to true, it | > works with no problem, the designer sets the value I've said... | > | | Thanks Jay, I'll try today and I'll tell how it works.
Jay B. Harlow [MVP - Outlook] ha escrito: Show quoteHide quote > Marina, > He has Me.AutoSize = False in his constructor. His overridden Property then > does a MyBase.AutoSize = false. Net effect is the same thing. > > | I thought the DefaultValue attribute just determines whether or not design > | time code is generated when the property is the default value. > Ah! There's the rub! or should I say there's the bug! > > The DefaultValueAttribute determines whether or not design time code is > generated. The constructor determines the runtime code. > > > Well apparently in the case of Label, the new .NET 2.0 layout manager > decides to ignore both & applies AutoSize = True to the control... > > A fellow MVP uses the following code as a workaround: > > Public Class LabelEx > Inherits System.Windows.Forms.Label > > Private m_inited As Boolean > > Sub New() > MyBase.New() > Me.ForeColor = Color.Black > Me.AutoSize = False > Me.Height = 16 > End Sub > > Protected Overrides Sub InitLayout() > MyBase.InitLayout() > m_inited = True > End Sub > > > <System.ComponentModel.DefaultValue(False)> _ > Public Overrides Property AutoSize() As Boolean > Get > Return MyBase.AutoSize > End Get > Set(ByVal value As Boolean) > If Me.DesignMode AndAlso Not m_inited Then Return > MyBase.AutoSize = value > End Set > End Property > > End Class > > > > -- > Hope this helps > Jay B. Harlow [MVP - Outlook] > .NET Application Architect, Enthusiast, & Evangelist > T.S. Bradley - http://www.tsbradley.net > > > "Marina Levit [MVP]" <someone@nospam.com> wrote in message > news:OHw7k0VkGHA.3304@TK2MSFTNGP03.phx.gbl... > | Wouldn't you have to in your constructor set MyBase.AutoSize = False? > | > | I thought the DefaultValue attribute just determines whether or not design > | time code is generated when the property is the default value. When the > | property is already the default value, it doesn't bother generating the > line > | of code, and the property value is not bold in the properties window. When > | it's anything other then the default, only then does it bother generating > a > | line for it, and then it looks bold in the properties window so it's > easier > | to tell you've modified it. > | > | "Jordi Rico" <jordir***@gmail.com> wrote in message > | news:1150454592.642448.18680@u72g2000cwu.googlegroups.com... > | > Hi, I've made the next inherited class in Visual Studio 2005: > | > > | > Public Class LabelEx > | > Inherits System.Windows.Forms.Label > | > > | > Sub New() > | > MyBase.New() > | > Me.ForeColor = Color.Black > | > Me.AutoSize = False > | > Me.Height = 16 > | > End Sub > | > > | > <System.ComponentModel.DefaultValue(False)> _ > | > Public Overrides Property AutoSize() As Boolean > | > Get > | > Return MyBase.AutoSize > | > End Get > | > Set(ByVal value As Boolean) > | > MyBase.AutoSize = value > | > End Set > | > End Property > | > End Class > | > > | > The problem is that Autosize Property remains always as true when I go > | > to design mode and put my LabelEx from the ToolBox to the form. Looking > | > at the designer file, I can see as every property I have set to all my > | > other extended controls is correct, except from autosize for labels... > | > Any idea??? I've been unable to find this anywhere, and it looks like a > | > bug, doesn't it? By the way, this code works properly in VS 2003, and > | > although the default in 2003 is Autosize=false, if I put it to true, it > | > works with no problem, the designer sets the value I've said... > | > > | > | Ok,
it works great! Thank you very much! Jordi Rico ha escrito: Show quoteHide quote > Thanks Jay, I'll try today and I'll tell how it works. > > Jay B. Harlow [MVP - Outlook] ha escrito: > > > Marina, > > He has Me.AutoSize = False in his constructor. His overridden Property then > > does a MyBase.AutoSize = false. Net effect is the same thing. > > > > | I thought the DefaultValue attribute just determines whether or not design > > | time code is generated when the property is the default value. > > Ah! There's the rub! or should I say there's the bug! > > > > The DefaultValueAttribute determines whether or not design time code is > > generated. The constructor determines the runtime code. > > > > > > Well apparently in the case of Label, the new .NET 2.0 layout manager > > decides to ignore both & applies AutoSize = True to the control... > > > > A fellow MVP uses the following code as a workaround: > > > > Public Class LabelEx > > Inherits System.Windows.Forms.Label > > > > Private m_inited As Boolean > > > > Sub New() > > MyBase.New() > > Me.ForeColor = Color.Black > > Me.AutoSize = False > > Me.Height = 16 > > End Sub > > > > Protected Overrides Sub InitLayout() > > MyBase.InitLayout() > > m_inited = True > > End Sub > > > > > > <System.ComponentModel.DefaultValue(False)> _ > > Public Overrides Property AutoSize() As Boolean > > Get > > Return MyBase.AutoSize > > End Get > > Set(ByVal value As Boolean) > > If Me.DesignMode AndAlso Not m_inited Then Return > > MyBase.AutoSize = value > > End Set > > End Property > > > > End Class > > > > > > > > -- > > Hope this helps > > Jay B. Harlow [MVP - Outlook] > > .NET Application Architect, Enthusiast, & Evangelist > > T.S. Bradley - http://www.tsbradley.net > > > > > > "Marina Levit [MVP]" <someone@nospam.com> wrote in message > > news:OHw7k0VkGHA.3304@TK2MSFTNGP03.phx.gbl... > > | Wouldn't you have to in your constructor set MyBase.AutoSize = False? > > | > > | I thought the DefaultValue attribute just determines whether or not design > > | time code is generated when the property is the default value. When the > > | property is already the default value, it doesn't bother generating the > > line > > | of code, and the property value is not bold in the properties window. When > > | it's anything other then the default, only then does it bother generating > > a > > | line for it, and then it looks bold in the properties window so it's > > easier > > | to tell you've modified it. > > | > > | "Jordi Rico" <jordir***@gmail.com> wrote in message > > | news:1150454592.642448.18680@u72g2000cwu.googlegroups.com... > > | > Hi, I've made the next inherited class in Visual Studio 2005: > > | > > > | > Public Class LabelEx > > | > Inherits System.Windows.Forms.Label > > | > > > | > Sub New() > > | > MyBase.New() > > | > Me.ForeColor = Color.Black > > | > Me.AutoSize = False > > | > Me.Height = 16 > > | > End Sub > > | > > > | > <System.ComponentModel.DefaultValue(False)> _ > > | > Public Overrides Property AutoSize() As Boolean > > | > Get > > | > Return MyBase.AutoSize > > | > End Get > > | > Set(ByVal value As Boolean) > > | > MyBase.AutoSize = value > > | > End Set > > | > End Property > > | > End Class > > | > > > | > The problem is that Autosize Property remains always as true when I go > > | > to design mode and put my LabelEx from the ToolBox to the form. Looking > > | > at the designer file, I can see as every property I have set to all my > > | > other extended controls is correct, except from autosize for labels... > > | > Any idea??? I've been unable to find this anywhere, and it looks like a > > | > bug, doesn't it? By the way, this code works properly in VS 2003, and > > | > although the default in 2003 is Autosize=false, if I put it to true, it > > | > works with no problem, the designer sets the value I've said... > > | > > > | > > | Thank you for following up that it worked!
-- Show quoteHide quoteHope this helps Jay B. Harlow [MVP - Outlook] ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "Jordi Rico" <jordir***@gmail.com> wrote in message news:1150730972.172249.182080@p79g2000cwp.googlegroups.com... | Ok, | it works great! | Thank you very much! | | Jordi Rico ha escrito: | | > Thanks Jay, I'll try today and I'll tell how it works. | > | > Jay B. Harlow [MVP - Outlook] ha escrito: | > | > > Marina, | > > He has Me.AutoSize = False in his constructor. His overridden Property then | > > does a MyBase.AutoSize = false. Net effect is the same thing. | > > | > > | I thought the DefaultValue attribute just determines whether or not design | > > | time code is generated when the property is the default value. | > > Ah! There's the rub! or should I say there's the bug! | > > | > > The DefaultValueAttribute determines whether or not design time code is | > > generated. The constructor determines the runtime code. | > > | > > | > > Well apparently in the case of Label, the new .NET 2.0 layout manager | > > decides to ignore both & applies AutoSize = True to the control... | > > | > > A fellow MVP uses the following code as a workaround: | > > | > > Public Class LabelEx | > > Inherits System.Windows.Forms.Label | > > | > > Private m_inited As Boolean | > > | > > Sub New() | > > MyBase.New() | > > Me.ForeColor = Color.Black | > > Me.AutoSize = False | > > Me.Height = 16 | > > End Sub | > > | > > Protected Overrides Sub InitLayout() | > > MyBase.InitLayout() | > > m_inited = True | > > End Sub | > > | > > | > > <System.ComponentModel.DefaultValue(False)> _ | > > Public Overrides Property AutoSize() As Boolean | > > Get | > > Return MyBase.AutoSize | > > End Get | > > Set(ByVal value As Boolean) | > > If Me.DesignMode AndAlso Not m_inited Then Return | > > MyBase.AutoSize = value | > > End Set | > > End Property | > > | > > End Class | > > | > > | > > | > > -- | > > Hope this helps | > > Jay B. Harlow [MVP - Outlook] | > > .NET Application Architect, Enthusiast, & Evangelist | > > T.S. Bradley - http://www.tsbradley.net | > > | > > | > > "Marina Levit [MVP]" <someone@nospam.com> wrote in message | > > news:OHw7k0VkGHA.3304@TK2MSFTNGP03.phx.gbl... | > > | Wouldn't you have to in your constructor set MyBase.AutoSize = False? | > > | | > > | I thought the DefaultValue attribute just determines whether or not design | > > | time code is generated when the property is the default value. When the | > > | property is already the default value, it doesn't bother generating the | > > line | > > | of code, and the property value is not bold in the properties window. When | > > | it's anything other then the default, only then does it bother generating | > > a | > > | line for it, and then it looks bold in the properties window so it's | > > easier | > > | to tell you've modified it. | > > | | > > | "Jordi Rico" <jordir***@gmail.com> wrote in message | > > | news:1150454592.642448.18680@u72g2000cwu.googlegroups.com... | > > | > Hi, I've made the next inherited class in Visual Studio 2005: | > > | > | > > | > Public Class LabelEx | > > | > Inherits System.Windows.Forms.Label | > > | > | > > | > Sub New() | > > | > MyBase.New() | > > | > Me.ForeColor = Color.Black | > > | > Me.AutoSize = False | > > | > Me.Height = 16 | > > | > End Sub | > > | > | > > | > <System.ComponentModel.DefaultValue(False)> _ | > > | > Public Overrides Property AutoSize() As Boolean | > > | > Get | > > | > Return MyBase.AutoSize | > > | > End Get | > > | > Set(ByVal value As Boolean) | > > | > MyBase.AutoSize = value | > > | > End Set | > > | > End Property | > > | > End Class | > > | > | > > | > The problem is that Autosize Property remains always as true when I go | > > | > to design mode and put my LabelEx from the ToolBox to the form. Looking | > > | > at the designer file, I can see as every property I have set to all my | > > | > other extended controls is correct, except from autosize for labels... | > > | > Any idea??? I've been unable to find this anywhere, and it looks like a | > > | > bug, doesn't it? By the way, this code works properly in VS 2003, and | > > | > although the default in 2003 is Autosize=false, if I put it to true, it | > > | > works with no problem, the designer sets the value I've said... | > > | > | > > | | > > | | I was able to duplicated with the VS 2005 Team Suite. I also added a
msgbox in the set method to monitor the value, ie <System.ComponentModel.DefaultValue(False)> _ Public Overrides Property AutoSize() As Boolean Get Return MyBase.AutoSize End Get Set(ByVal value As Boolean) msgbox(value) MyBase.AutoSize = value End Set End Property Wether the defaultvalue is true or false, I get two windows in design time: first one says false, second one says true. Jordi Rico wrote: Show quoteHide quote > Hi, I've made the next inherited class in Visual Studio 2005: > > Public Class LabelEx > Inherits System.Windows.Forms.Label > > Sub New() > MyBase.New() > Me.ForeColor = Color.Black > Me.AutoSize = False > Me.Height = 16 > End Sub > > <System.ComponentModel.DefaultValue(False)> _ > Public Overrides Property AutoSize() As Boolean > Get > Return MyBase.AutoSize > End Get > Set(ByVal value As Boolean) > MyBase.AutoSize = value > End Set > End Property > End Class > > The problem is that Autosize Property remains always as true when I go > to design mode and put my LabelEx from the ToolBox to the form. Looking > at the designer file, I can see as every property I have set to all my > other extended controls is correct, except from autosize for labels... > Any idea??? I've been unable to find this anywhere, and it looks like a > bug, doesn't it? By the way, this code works properly in VS 2003, and > although the default in 2003 is Autosize=false, if I put it to true, it > works with no problem, the designer sets the value I've said...
AntiAlias
Wlan - VB.NET urgent! dataset updation in wrong row accessing TypeConverter from code I don't get this --> Make Thread-Safe Calls to Windows Forms Controls Exception.ToString() VB and VB.NET Adding text to a jpeg file Whats best event for changing related data in child table Wizard for UserControl |
|||||||||||||||||||||||