Hi all
i have a class that i have made and i made an Typeconverter as well, and my
problem is
the code genereated in my form is
Dim ClassTest1 As TestApplication.ClassTest = New TestApplication.ClassTest
Me.MyClassTest = ClassTest1
Wich is quite good, but my problem is in my property browser i cannot change
any of my properties
' need the "DesignerSerializationVisibility " this in visible because this
is a form that must be inherited and i don´t want this property tobe writen
in the child form. unless it was changed in the child form .
i have declare my property like this
<LocalizableAttribute(True), _
Browsable(True), _
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Visible), _
MergableProperty(False)> _
Public Property MyClassTest() As ClassTest
Get
Return xMyClassTest
End Get
Set(ByVal Value As ClassTest)
xMyClassTest = Value
xMyClassTest_ChangedProperty()
End Set
End Property
please see the code below
<System.ComponentModel.TypeConverter(GetType(Class TypeConverter)), _
EditorBrowsable(EditorBrowsableState.Always), _
Serializable()> _
Public Class ClassTest
Inherits System.MarshalByRefObject
Implements System.IDisposable
Private xText As String = "Texto"
Private xColor As System.Drawing.Color = Color.Red
Public Event ChangedProperty()
Event testesss As EventHandler
Public Property Text() As String
Get
Return xText
End Get
Set(ByVal Value As String)
xText = Value
RaiseEvent ChangedProperty()
End Set
End Property
Public Property Color() As System.Drawing.Color
Get
Return xColor
End Get
Set(ByVal Value As System.Drawing.Color)
xColor = Value
RaiseEvent ChangedProperty()
End Set
End Property
<EditorBrowsable(EditorBrowsableState.Advanced)> _
Private Function ShouldSerializeColor() As Boolean
Return Not Me.Color.Equals(Color.Red)
End Function
<EditorBrowsable(EditorBrowsableState.Advanced)> _
Private Sub ResetColor()
Me.Color = Color.Red
End Sub
<EditorBrowsable(EditorBrowsableState.Advanced)> _
Private Function ShouldSerializeText() As Boolean
Return Me.Text <> "Texto"
End Function
<EditorBrowsable(EditorBrowsableState.Advanced)> _
Private Sub ResetText()
xText = "Texto"
End Sub
Public Sub Dispose() Implements System.IDisposable.Dispose
xColor = Nothing
End Sub
End Class
' Type Converter Class
Imports System.Reflection
Imports System.ComponentModel
Imports System
Imports System.Drawing
Imports System.Drawing.Design
Imports System.ComponentModel.Design.Serialization
Public Class ClassTypeConverter
Inherits ExpandableObjectConverter
Public Overloads Overrides Function CanConvertTo(ByVal context As
System.ComponentModel.ITypeDescriptorContext, ByVal destinationType As
System.Type) As Boolean
Try
If destinationType Is GetType(InstanceDescriptor) Then
Return True
End If
Return MyBase.CanConvertTo(context, destinationType)
Catch ex As Exception
MessageBox.Show("Erro CanConvertTo " & ex.StackTrace)
End Try
End Function
Public Overloads Overrides Function ConvertTo(ByVal context As
System.ComponentModel.ITypeDescriptorContext, ByVal culture As
System.Globalization.CultureInfo, ByVal value As Object, ByVal
destinationType As System.Type) As Object
Try
If destinationType Is Nothing Then
Throw New ArgumentNullException("Argumentos Invalidos")
End If
If destinationType Is GetType(InstanceDescriptor) Then
Dim ci As ConstructorInfo =
GetType(ClassTest).GetConstructor(Type.EmptyTypes)
Return New InstanceDescriptor(ci, Nothing, False)
End If
Return MyBase.ConvertTo(context, culture, value, destinationType)
Catch ex As Exception
MessageBox.Show("Erro ConvertTo" & ex.StackTrace)
End Try
End Function
Public Overloads Overrides Function CreateInstance(ByVal context As
System.ComponentModel.ITypeDescriptorContext, ByVal propertyValues As
System.Collections.IDictionary) As Object
Return New ClassTest 'Activator.CreateInstance(GetType(ClassTest))
End Function
Public Overloads Overrides Function GetCreateInstanceSupported(ByVal context
As System.ComponentModel.ITypeDescriptorContext) As Boolean
Return True
End Function
End Class 2 2163
hi there ,,
just try to put aonther property in your MyProperty structure but not add it
to the constructor.
and then try to change the vaule at design time. :(
thsk
JSB
"joeycalisay" <hcalisay@_spamkiller_codex-systems.com> wrote in message
news:uX**************@TK2MSFTNGP10.phx.gbl... sorry but i cannot do a vb.net equivalent.
try to browse my attached example to get some ideas...
-- Joey Calisay http://spaces.msn.com/members/joeycalisay/
"João Santa Bárbara" <jo****@i24portugal.com> wrote in message news:eD**************@tk2msftngp13.phx.gbl... Hi all i have a class that i have made and i made an Typeconverter as well, and my problem is the code genereated in my form is
Dim ClassTest1 As TestApplication.ClassTest = New TestApplication.ClassTest Me.MyClassTest = ClassTest1
Wich is quite good, but my problem is in my property browser i cannot change any of my properties ' need the "DesignerSerializationVisibility " this in visible because this is a form that must be inherited and i don´t want this property tobe writen in the child form. unless it was changed in the child form .
i have declare my property like this
<LocalizableAttribute(True), _ Browsable(True), _ DesignerSerializationVisibility(DesignerSerializat ionVisibility.Visible), _ MergableProperty(False)> _ Public Property MyClassTest() As ClassTest Get Return xMyClassTest End Get Set(ByVal Value As ClassTest) xMyClassTest = Value xMyClassTest_ChangedProperty() End Set End Property please see the code below
<System.ComponentModel.TypeConverter(GetType(Class TypeConverter)), _ EditorBrowsable(EditorBrowsableState.Always), _ Serializable()> _ Public Class ClassTest Inherits System.MarshalByRefObject Implements System.IDisposable Private xText As String = "Texto" Private xColor As System.Drawing.Color = Color.Red Public Event ChangedProperty() Event testesss As EventHandler Public Property Text() As String Get Return xText End Get Set(ByVal Value As String) xText = Value RaiseEvent ChangedProperty() End Set End Property Public Property Color() As System.Drawing.Color Get Return xColor End Get Set(ByVal Value As System.Drawing.Color) xColor = Value RaiseEvent ChangedProperty() End Set End Property <EditorBrowsable(EditorBrowsableState.Advanced)> _ Private Function ShouldSerializeColor() As Boolean Return Not Me.Color.Equals(Color.Red) End Function <EditorBrowsable(EditorBrowsableState.Advanced)> _ Private Sub ResetColor() Me.Color = Color.Red End Sub <EditorBrowsable(EditorBrowsableState.Advanced)> _ Private Function ShouldSerializeText() As Boolean Return Me.Text <> "Texto" End Function <EditorBrowsable(EditorBrowsableState.Advanced)> _ Private Sub ResetText() xText = "Texto" End Sub
Public Sub Dispose() Implements System.IDisposable.Dispose xColor = Nothing End Sub End Class
' Type Converter Class Imports System.Reflection Imports System.ComponentModel Imports System Imports System.Drawing Imports System.Drawing.Design Imports System.ComponentModel.Design.Serialization Public Class ClassTypeConverter Inherits ExpandableObjectConverter Public Overloads Overrides Function CanConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal destinationType As System.Type) As Boolean Try If destinationType Is GetType(InstanceDescriptor) Then Return True End If Return MyBase.CanConvertTo(context, destinationType) Catch ex As Exception MessageBox.Show("Erro CanConvertTo " & ex.StackTrace) End Try End Function Public Overloads Overrides Function ConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, ByVal value As Object, ByVal destinationType As System.Type) As Object Try If destinationType Is Nothing Then Throw New ArgumentNullException("Argumentos Invalidos") End If If destinationType Is GetType(InstanceDescriptor) Then Dim ci As ConstructorInfo = GetType(ClassTest).GetConstructor(Type.EmptyTypes) Return New InstanceDescriptor(ci, Nothing, False) End If Return MyBase.ConvertTo(context, culture, value, destinationType) Catch ex As Exception MessageBox.Show("Erro ConvertTo" & ex.StackTrace) End Try End Function
Public Overloads Overrides Function CreateInstance(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal propertyValues As System.Collections.IDictionary) As Object Return New ClassTest 'Activator.CreateInstance(GetType(ClassTest)) End Function Public Overloads Overrides Function GetCreateInstanceSupported(ByVal context As System.ComponentModel.ITypeDescriptorContext) As Boolean Return True End Function
End Class
and why would you not add it to the constructor of the struct? I believe
you have to because you will be instructing your TypeConverter which
constructor to use and if you will be using the old one (my two parameter
constructor), how will you serialize the value for the additional property?
Perhaps you can customize that with a custom CodeDom but it will be really
easier (and practical IMO) if your constructor (which the typeconverter will
use) properly initializes your struct instance...
--
Joey Calisay http://spaces.msn.com/members/joeycalisay/
"João Santa Bárbara" <jo****@i24portugal.com> wrote in message
news:uo**************@TK2MSFTNGP14.phx.gbl... hi there ,, just try to put aonther property in your MyProperty structure but not add
it to the constructor. and then try to change the vaule at design time. :( thsk JSB "joeycalisay" <hcalisay@_spamkiller_codex-systems.com> wrote in message news:uX**************@TK2MSFTNGP10.phx.gbl... sorry but i cannot do a vb.net equivalent.
try to browse my attached example to get some ideas...
-- Joey Calisay http://spaces.msn.com/members/joeycalisay/
"João Santa Bárbara" <jo****@i24portugal.com> wrote in message news:eD**************@tk2msftngp13.phx.gbl... Hi all i have a class that i have made and i made an Typeconverter as well,
and my problem is the code genereated in my form is
Dim ClassTest1 As TestApplication.ClassTest = New TestApplication.ClassTest Me.MyClassTest = ClassTest1
Wich is quite good, but my problem is in my property browser i cannot change any of my properties ' need the "DesignerSerializationVisibility " this in visible because this is a form that must be inherited and i don´t want this property tobe writen in the child form. unless it was changed in the child form .
i have declare my property like this
<LocalizableAttribute(True), _ Browsable(True), _
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Visible), _ MergableProperty(False)> _ Public Property MyClassTest() As ClassTest Get Return xMyClassTest End Get Set(ByVal Value As ClassTest) xMyClassTest = Value xMyClassTest_ChangedProperty() End Set End Property please see the code below
<System.ComponentModel.TypeConverter(GetType(Class TypeConverter)), _ EditorBrowsable(EditorBrowsableState.Always), _ Serializable()> _ Public Class ClassTest Inherits System.MarshalByRefObject Implements System.IDisposable Private xText As String = "Texto" Private xColor As System.Drawing.Color = Color.Red Public Event ChangedProperty() Event testesss As EventHandler Public Property Text() As String Get Return xText End Get Set(ByVal Value As String) xText = Value RaiseEvent ChangedProperty() End Set End Property Public Property Color() As System.Drawing.Color Get Return xColor End Get Set(ByVal Value As System.Drawing.Color) xColor = Value RaiseEvent ChangedProperty() End Set End Property <EditorBrowsable(EditorBrowsableState.Advanced)> _ Private Function ShouldSerializeColor() As Boolean Return Not Me.Color.Equals(Color.Red) End Function <EditorBrowsable(EditorBrowsableState.Advanced)> _ Private Sub ResetColor() Me.Color = Color.Red End Sub <EditorBrowsable(EditorBrowsableState.Advanced)> _ Private Function ShouldSerializeText() As Boolean Return Me.Text <> "Texto" End Function <EditorBrowsable(EditorBrowsableState.Advanced)> _ Private Sub ResetText() xText = "Texto" End Sub
Public Sub Dispose() Implements System.IDisposable.Dispose xColor = Nothing End Sub End Class
' Type Converter Class Imports System.Reflection Imports System.ComponentModel Imports System Imports System.Drawing Imports System.Drawing.Design Imports System.ComponentModel.Design.Serialization Public Class ClassTypeConverter Inherits ExpandableObjectConverter Public Overloads Overrides Function CanConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal destinationType As System.Type) As Boolean Try If destinationType Is GetType(InstanceDescriptor) Then Return True End If Return MyBase.CanConvertTo(context, destinationType) Catch ex As Exception MessageBox.Show("Erro CanConvertTo " & ex.StackTrace) End Try End Function Public Overloads Overrides Function ConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, ByVal value As Object, ByVal destinationType As System.Type) As Object Try If destinationType Is Nothing Then Throw New ArgumentNullException("Argumentos Invalidos") End If If destinationType Is GetType(InstanceDescriptor) Then Dim ci As ConstructorInfo = GetType(ClassTest).GetConstructor(Type.EmptyTypes) Return New InstanceDescriptor(ci, Nothing, False) End If Return MyBase.ConvertTo(context, culture, value, destinationType) Catch ex As Exception MessageBox.Show("Erro ConvertTo" & ex.StackTrace) End Try End Function
Public Overloads Overrides Function CreateInstance(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal propertyValues As System.Collections.IDictionary) As Object Return New ClassTest 'Activator.CreateInstance(GetType(ClassTest)) End Function Public Overloads Overrides Function GetCreateInstanceSupported(ByVal context As System.ComponentModel.ITypeDescriptorContext) As Boolean Return True End Function
End Class
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: João Santa Bárbara |
last post by:
Hi all
i have a class that i have made and i made an Typeconverter as well, and my
problem is
the code genereated in my form is
Dim ClassTest1 As TestApplication.ClassTest = New...
|
by: kw |
last post by:
I'm getting different behavior from what I would expect and was hoping
someone could clue me in. At run time I need to examine a property of an
object for a custom TypeConverter, then use that...
|
by: Sky Sigal |
last post by:
(PS: Cross post from microsoft.pulic.dotnet.framework.aspnet.webcontrols)
I've been looking lately for a way to keep the Properties panel for Controls
'clean'...
My goal is to keep similar...
|
by: Oskar Vaia |
last post by:
Hi,
in the .NET Framework Class Library there is the following text in the
"Remarks"-section:
"Use this method for objects that are immutable, but for which you want to
provide changeable...
|
by: João Santa Bárbara |
last post by:
Hi all
i have a class that i have made and i made an Typeconverter as well, and my
problem is
the code genereated in my form is
Dim ClassTest1 As TestApplication.ClassTest = New...
|
by: Alex Clark |
last post by:
Hi all,
Apologies for the cross-post but I can't determine if this is a VS .NET
problem or a VB.NET language issue. I'm using .NET 1.1 SP1, VS 2003 EA,
VB.NET.
I'm coding a custom component...
|
by: Matthias Heise |
last post by:
Hello everybody,
I have a problem towards the following topic.
There is a class like MyColor and a class like MyRectangle that has a
property called FillColor which is of type MyColor. Now it...
|
by: ismail.mayat |
last post by:
Hello,
I am having a problem with Activator.CreateInstance. I have the
following code
Assembly asm = System.Reflection.Assembly.LoadFrom(assembly);
if(asm!=null)
{
try
{
|
by: Rolf Welskes |
last post by:
Hello,
the problem seems to be complex and is in all developments of web-controls
which uses own TypeConverter.
For this I have here a simple demo-program of the problem:
The Control-code: A...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |