Re: User style collection editor for GridTableStylesCollection
- From: "Lincon Marine Service" <lincon@xxxxxxxxxxxxxx>
- Date: Wed, 28 Sep 2005 08:54:58 +0800
Thanks AMDRIT ..
Thank for your help .....very much
I get it and solve this problem
Michael
"AMDRIT" <amdrit@xxxxxxxxxxx> ¦b¶l¥ó
news:etHlUn6wFHA.3312@xxxxxxxxxxxxxxxxxxxx ¤¤¼¶¼g...
> I am working a very similar project and am running into an issue getting
the
> values to save during design time. Perhaps we can share notes?
>
> If anyone else has any ideas where I am going wrong, please let me know.
> Thanks.
>
> Here is what I have:
>
> <Serializable(), _
> ToolboxItem(True), _
> TypeConverter(GetType(DatatableManager.DatatableManagerTypeConverter))>
_
> Public Class DatatableManager
> Inherits System.ComponentModel.Component
>
> #Region " Declarations"
> Private m_AllowSorting As Boolean = False
> Private m_AlternatingBackColor As Color = System.Drawing.Color.White
> Private m_BackColor As Color = System.Drawing.Color.White
> Private m_ColumnHeadersVisible As Boolean = True
> Private m_ForeColor As Color =
> System.Drawing.Color.FromKnownColor(KnownColor.WindowText)
> Private m_GridLineColor As Color =
> System.Drawing.Color.FromKnownColor(KnownColor.Control)
> Private m_GridLineStyle As DataGridLineStyle
> Private m_HeaderBackColor As Color =
> System.Drawing.Color.FromKnownColor(KnownColor.Control)
> Private m_HeaderFont As Font = New Font("Microsoft Sans Serif", 8.25)
> Private m_HeaderForeColor As Color =
> System.Drawing.Color.FromKnownColor(KnownColor.ControlText)
> Private m_LinkColor As Color =
> System.Drawing.Color.FromKnownColor(KnownColor.HotTrack)
> Private m_MappingName As String = ""
> Private m_PreferredColumnWidth As Integer = 75
> Private m_PreferredRowHeight As Integer = 16
> Private m_ReadOnly As Boolean = False
> Private m_RowHeadersVisible As Boolean = True
> Private m_RowHeaderWidth As Integer = 35
> Private m_SelectionBackColor As Color =
> System.Drawing.Color.FromKnownColor(KnownColor.ActiveCaption)
> Private m_SelectionForeColor As Color =
> System.Drawing.Color.FromKnownColor(KnownColor.ActiveCaptionText)
> Private m_Columns As Columns
> #End Region
>
> #Region " Component Designer generated code "
>
> Public Sub New(ByVal Container As System.ComponentModel.IContainer)
> MyClass.New()
>
> 'Required for Windows.Forms Class Composition Designer support
> Container.Add(Me)
> m_Columns = New Columns
> End Sub
>
> Public Sub New()
> MyBase.New()
>
> 'This call is required by the Component Designer.
> InitializeComponent()
>
> 'Add any initialization after the InitializeComponent() call
> End Sub
>
> 'Component overrides dispose to clean up the component list.
> Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
> If disposing Then
> If Not (components Is Nothing) Then
> components.Dispose()
> End If
> End If
> MyBase.Dispose(disposing)
> End Sub
>
> 'Required by the Component Designer
> Private components As System.ComponentModel.IContainer
>
> 'NOTE: The following procedure is required by the Component Designer
> 'It can be modified using the Component Designer.
> 'Do not modify it using the code editor.
> <System.Diagnostics.DebuggerStepThrough()> Private Sub
> InitializeComponent()
> components = New System.ComponentModel.Container
> End Sub
>
> #End Region
>
> #Region " Properties"
>
> <Description("Indicates whether sorting is allowed on the grid table
when
> this DataGridTableStyle is used."), _
> Category("Usability")> _
> Public Property AllowSorting() As Boolean
> Get
> Return m_AllowSorting
> End Get
> Set(ByVal Value As Boolean)
> m_AllowSorting = Value
> End Set
> End Property
> <Description("Gets or sets the background color of odd-numbered rows of
> the grid."), _
> Category("Appearance")> _
> Public Property AlternatingBackColor() As Color
> Get
> Return m_AlternatingBackColor
> End Get
> Set(ByVal Value As Color)
> m_AlternatingBackColor = Value
> End Set
> End Property
> <Description("Gets or sets the background color of even-numbered rows of
> the grid."), _
> Category("Appearance")> _
> Public Property BackColor() As Color
> Get
> Return m_BackColor
> End Get
> Set(ByVal Value As Color)
> m_BackColor = Value
> End Set
> End Property
> <Description("Gets or sets a value indicating whether column headers are
> visible."), _
> Category("Appearance")> _
> Public Property ColumnHeadersVisible() As Boolean
> Get
> Return m_ColumnHeadersVisible
> End Get
> Set(ByVal Value As Boolean)
> m_ColumnHeadersVisible = Value
> End Set
> End Property
> <Description("Gets or sets the foreground color of the grid table."), _
> Category("Appearance"), _
> DefaultValue(True)> _
> Public Property ForeColor() As Color
> Get
> Return m_ForeColor
> End Get
> Set(ByVal Value As Color)
> m_ForeColor = Value
> End Set
> End Property
> <Description("Gets or sets the color of grid lines."), _
> Category("Appearance")> _
> Public Property GridLineColor() As Color
> Get
> Return m_GridLineColor
> End Get
> Set(ByVal Value As Color)
> m_GridLineColor = Value
> End Set
> End Property
> <Description("Gets or sets the style of grid lines."), _
> Category("Appearance")> _
> Public Property GridLineStyle() As DataGridLineStyle
> Get
> Return m_GridLineStyle
> End Get
> Set(ByVal Value As DataGridLineStyle)
> m_GridLineStyle = Value
> End Set
> End Property
> <Description("Gets or sets the background color of headers."), _
> Category("Appearance")> _
> Public Property HeaderBackColor() As Color
> Get
> Return m_HeaderBackColor
> End Get
> Set(ByVal Value As Color)
> m_HeaderBackColor = Value
> End Set
> End Property
> <Description("Gets or sets the font used for header captions."), _
> Category("Appearance")> _
> Public Property HeaderFont() As Font
> Get
> Return m_HeaderFont
> End Get
> Set(ByVal Value As Font)
> m_HeaderFont = Value
> End Set
> End Property
> <Description("Gets or sets the foreground color of headers."), _
> Category("Appearance")> _
> Public Property HeaderForeColor() As Color
> Get
> Return m_HeaderForeColor
> End Get
> Set(ByVal Value As Color)
> m_HeaderForeColor = Value
> End Set
> End Property
> <Description("Gets or sets the color of link text."), _
> Category("Appearance")> _
> Public Property LinkColor() As Color
> Get
> Return m_LinkColor
> End Get
> Set(ByVal Value As Color)
> m_LinkColor = Value
> End Set
> End Property
> <Description("Gets or sets the name used to map this table to a specific
> data source."), _
> Category("General")> _
> Public Property MappingName() As String
> Get
> Return m_MappingName
> End Get
> Set(ByVal Value As String)
> m_MappingName = Value
> End Set
> End Property
> <Description("Gets or sets the width used to create columns when a new
> grid is displayed."), _
> Category("General")> _
> Public Property PreferredColumnWidth() As Integer
> Get
> Return m_PreferredColumnWidth
> End Get
> Set(ByVal Value As Integer)
> m_PreferredColumnWidth = Value
> End Set
> End Property
> <Description("Gets or sets the height used to create a row when a new
grid
> is displayed."), _
> Category("Appearance")> _
> Public Property PreferredRowHeight() As Integer
> Get
> Return m_PreferredRowHeight
> End Get
> Set(ByVal Value As Integer)
> m_PreferredRowHeight = Value
> End Set
> End Property
> <Description("Gets or sets a value indicating whether columns can be
> edited."), _
> Category("Usability")> _
> Public Property [ReadOnly]() As Boolean
> Get
> Return m_ReadOnly
> End Get
> Set(ByVal Value As Boolean)
> m_ReadOnly = Value
> End Set
> End Property
> <Description("Gets or sets a value indicating whether row headers are
> visible."), _
> Category("Appearance")> _
> Public Property RowHeadersVisible() As Boolean
> Get
> Return m_RowHeadersVisible
> End Get
> Set(ByVal Value As Boolean)
> m_RowHeadersVisible = Value
> End Set
> End Property
> <Description("Gets or sets the width of row headers."), _
> Category("Appearance")> _
> Public Property RowHeaderWidth() As Integer
> Get
> Return m_RowHeaderWidth
> End Get
> Set(ByVal Value As Integer)
> m_RowHeaderWidth = Value
> End Set
> End Property
> <Description("Gets or sets the background color of selected cells."), _
> Category("Appearance")> _
> Public Property SelectionBackColor() As Color
> Get
> Return m_SelectionBackColor
> End Get
> Set(ByVal Value As Color)
> m_SelectionBackColor = Value
> End Set
> End Property
> <Description("Gets or sets the foreground color of selected cells."), _
> Category("Appearance")> _
> Public Property SelectionForeColor() As Color
> Get
> Return m_SelectionForeColor
> End Get
> Set(ByVal Value As Color)
> m_SelectionForeColor = Value
> End Set
> End Property
> <Description("Gets or sets the collection of columns available for
display
> in the datagrid."), _
> Category("Data"), _
>
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
> _
> Editor(GetType(ColumnCollectionEditor), GetType(UITypeEditor))> _
> Public Property Columns() As Columns
> Get
> Return m_Columns
> End Get
> Set(ByVal Value As Columns)
> m_Columns = Value
> End Set
> End Property
>
> #End Region
>
> Friend Class DatatableManagerTypeConverter
> Inherits ExpandableObjectConverter
>
> 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
> Return String.Format("Data table manager")
> End Function
>
> Public Overloads Function CanConvertFrom(ByVal context As
> System.ComponentModel.ITypeDescriptorContext, ByVal sourceType As
> System.Type) As Boolean
>
> If (sourceType Is GetType(String)) Then
> Return True
> End If
>
> Return MyBase.CanConvertFrom(context, sourceType)
>
> End Function
> End Class
>
> Friend Class DatatableManagerDesigner
> Inherits System.Windows.Forms.Design.ControlDesigner
>
> Private MyControl As DatatableManager
>
> Public Overrides Sub Initialize(ByVal component As IComponent)
>
> Try
> MyBase.Initialize(component)
>
> '// Record instance of control we're designing
> MyControl = DirectCast(component, DatatableManager)
>
> '// Hook up events
> Dim s As ISelectionService =
> DirectCast(GetService(GetType(ISelectionService)), ISelectionService)
> Dim c As IComponentChangeService =
> DirectCast(GetService(GetType(IComponentChangeService)),
> IComponentChangeService)
> AddHandler s.SelectionChanged, New EventHandler(AddressOf
> OnSelectionChanged)
> AddHandler c.ComponentRemoving, New
ComponentEventHandler(AddressOf
> OnComponentRemoving)
> Catch ex As Exception
> Debug.WriteLine(ex.ToString)
> End Try
> End Sub
>
> Private Sub OnSelectionChanged(ByVal sender As Object, ByVal e As
> System.EventArgs)
>
> 'MyControl.OnSelectionChanged()
>
> End Sub
>
> Private Sub OnComponentRemoving(ByVal sender As Object, ByVal e As
> ComponentEventArgs)
>
> Try
> Dim c As IComponentChangeService =
> DirectCast(GetService(GetType(IComponentChangeService)),
> IComponentChangeService)
> Dim bc As BaseColumn
> Dim h As IDesignerHost =
> DirectCast(GetService(GetType(IDesignerHost)), IDesignerHost)
>
> '// If the user is removing a button
> If (TypeOf e.Component Is BaseColumn) Then
>
> bc = DirectCast(e.Component, BaseColumn)
> If (MyControl.Columns.Contains(bc)) Then
>
> c.OnComponentChanging(MyControl, Nothing)
> MyControl.Columns.Remove(bc)
> c.OnComponentChanged(MyControl, Nothing, Nothing, Nothing)
> Return
> End If
> End If
>
> '// If the user is removing the control itself
> If (e.Component Is MyControl) Then
>
> For i As Int32 = MyControl.Columns.Count - 1 To 0 Step -1
>
> bc = MyControl.Columns(i)
> c.OnComponentChanging(MyControl, Nothing)
> MyControl.Columns.Remove(bc)
> h.DestroyComponent(bc)
> c.OnComponentChanged(MyControl, Nothing, Nothing, Nothing)
> Next i
>
> End If
> Catch ex As Exception
> Debug.WriteLine(ex.ToString)
> End Try
>
>
> End Sub
>
> Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
>
> Try
> Dim s As ISelectionService =
> DirectCast(GetService(GetType(ISelectionService)), ISelectionService)
> Dim c As IComponentChangeService =
> DirectCast(GetService(GetType(IComponentChangeService)),
> IComponentChangeService)
>
> '// Unhook events
> RemoveHandler s.SelectionChanged, New EventHandler(AddressOf
> OnSelectionChanged)
> RemoveHandler c.ComponentRemoving, New
> ComponentEventHandler(AddressOf OnComponentRemoving)
> Catch ex As Exception
> Debug.WriteLine(ex.ToString)
> End Try
>
> MyBase.Dispose(disposing)
>
> End Sub
>
> Public Overrides ReadOnly Property AssociatedComponents() As
> System.Collections.ICollection
> Get
>
> Try
> Return MyControl.Columns
> Catch ex As Exception
> Debug.WriteLine(ex.ToString)
> End Try
>
> End Get
> End Property
>
> Public Overrides ReadOnly Property Verbs() As
> System.ComponentModel.Design.DesignerVerbCollection
>
> Get
>
> Try
> Dim v As DesignerVerbCollection = New DesignerVerbCollection
>
> '// Verb to add buttons
> v.Add(New DesignerVerb("&Add Column", New EventHandler(AddressOf
> OnAddButton)))
>
> Return v
> Catch ex As Exception
> Debug.WriteLine(ex.ToString)
> End Try
>
> End Get
>
> End Property
>
> Private Sub OnAddButton(ByVal sender As Object, ByVal e As
> System.EventArgs)
>
> Try
> Dim bc As BaseColumn
> Dim h As IDesignerHost =
> DirectCast(GetService(GetType(IDesignerHost)), IDesignerHost)
> Dim dt As DesignerTransaction
> Dim c As IComponentChangeService =
> DirectCast(GetService(GetType(IComponentChangeService)),
> IComponentChangeService)
>
> '// Add a new button to the collection
> dt = h.CreateTransaction("Add Column")
> bc = DirectCast(h.CreateComponent(GetType(BaseColumn)),
BaseColumn)
> c.OnComponentChanging(MyControl, Nothing)
> MyControl.Columns.Add(bc)
> c.OnComponentChanged(MyControl, Nothing, Nothing, Nothing)
> dt.Commit()
> Catch ex As Exception
> Debug.WriteLine(ex.ToString)
> End Try
>
> End Sub
>
> End Class
>
>
> End Class
>
> #Region " Column Collection "
>
> '<TypeConverter(GetType(Columns.ColumnsTypeConverter))>
>
> Public Class Columns
> Inherits CollectionBase
>
> Event PropertyChaged()
>
>
'<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
>
> Default Public Property Item(ByVal index As Integer) As BaseColumn
> Get
> Try
> Return CType(List(index), BaseColumn)
> Catch ex As Exception
> Return Nothing
> End Try
> End Get
> Set(ByVal Value As BaseColumn)
> List(index) = Value
> End Set
> End Property
>
> Public Function Add(ByVal value As BaseColumn) As Integer
> Return List.Add(value)
> value.Collection = Me
> End Function 'Add
>
> Public Sub AddRange(ByVal Items() As BaseColumn)
> Dim Item As Object
> For Each Item In Items
> CType(Item, BaseColumn).Collection = Me
> list.Add(Item)
> Next
> End Sub
>
> Public Function IndexOf(ByVal value As BaseColumn) As Integer
> Return List.IndexOf(value)
> End Function 'IndexOf
>
> Public Sub Insert(ByVal index As Integer, ByVal value As BaseColumn)
> List.Insert(index, value)
> End Sub 'Insert
>
> Public Sub Remove(ByVal value As BaseColumn)
> List.Remove(value)
>
> End Sub 'Remove
>
> Public Function Contains(ByVal value As BaseColumn) As Boolean
> ' If value is not of type BaseColumn, this will return false.
> Return List.Contains(value)
> End Function 'Contains
>
> Protected Shadows Sub OnInsert(ByVal index As Integer, ByVal value As
> BaseColumn)
> ' Insert additional code to be run only when inserting values.
> End Sub 'OnInsert
>
> Protected Shadows Sub OnRemove(ByVal index As Integer, ByVal value As
> BaseColumn)
> ' Insert additional code to be run only when removing values.
> End Sub 'OnRemove
>
> Protected Shadows Sub OnSet(ByVal index As Integer, ByVal oldValue As
> BaseColumn, ByVal newValue As BaseColumn)
> ' Insert additional code to be run only when setting values.
> End Sub 'OnSet
>
> Protected Shadows Sub OnValidate(ByVal value As BaseColumn)
> 'If Not value.GetType() Is Type.GetType("BaseColumn") Then
> 'Throw New ArgumentException("value must be of type BaseColumn.",
> "value")
> 'End If
> End Sub 'OnValidate
>
> Friend Sub RaisePropertyChangedEvent()
> RaiseEvent PropertyChaged()
> End Sub
>
> Friend Class ColumnsTypeConverter
> Inherits ExpandableObjectConverter
>
> 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
> Return String.Format("Collection")
> End Function
>
> Public Overloads Function CanConvertFrom(ByVal context As
> System.ComponentModel.ITypeDescriptorContext, ByVal sourceType As
> System.Type) As Boolean
>
> If (sourceType Is GetType(String)) Then
> Return True
> End If
>
> Return MyBase.CanConvertFrom(context, sourceType)
>
> End Function
> End Class
>
> End Class
>
> #Region " ColumnCollectionEditor"
>
> Friend Class ColumnCollectionEditor
> Inherits System.ComponentModel.Design.CollectionEditor
>
> Private Types() As System.Type
> Private cf As CollectionForm
>
> Sub New(ByVal type As System.Type)
> MyBase.New(type)
> Types = New System.Type() {GetType(BaseColumn), GetType(TextColumn),
> GetType(CheckColumn)}
> End Sub
>
> Protected Overrides Function CreateNewItemTypes() As System.Type()
> Return Types
> End Function
>
> Protected Overrides Function CreateCollectionForm() As
> System.ComponentModel.Design.CollectionEditor.CollectionForm
> Me.cf = MyBase.CreateCollectionForm
> Return Me.cf
> End Function
>
> Protected Overloads Overrides Function CreateInstance(ByVal itemType As
> System.Type) As Object
>
> Dim blahblah As BaseColumn =
DirectCast(MyBase.CreateInstance(itemType),
> BaseColumn)
>
> If Not Me.Context.Instance Is Nothing Then
> End If
>
> Return blahblah
>
> End Function
>
> End Class
>
> #End Region
>
> #Region " Columns Types"
>
> <Serializable(), TypeConverter(GetType(BaseColumn.BaseColumnConverter))> _
> Public Class BaseColumn
> Inherits Component
>
> Public Enum ColumnTypes
> Base = 1
> Text = 2
> Bool = 3
> End Enum
>
> #Region " Declarations "
>
> Protected m_Alignment As System.Windows.Forms.HorizontalAlignment
> Protected m_HeaderText As String
> Protected m_MappingName As String
> Protected m_NullText As String
> Protected m_ReadOnly As Boolean
> Protected m_Width As Integer
> Protected m_Visible As Boolean
> Protected m_Collection As Columns
> Protected m_ColumnType As ColumnTypes
>
> #End Region
>
> #Region " Properties"
>
> <Description("Gets or sets the alignment of text in a column."), _
> Category("General"), _
> DefaultValue(System.Windows.Forms.HorizontalAlignment.Left)> _
> Public Property Alignment() As System.Windows.Forms.HorizontalAlignment
> Get
> Return m_Alignment
> End Get
> Set(ByVal Value As System.Windows.Forms.HorizontalAlignment)
> m_Alignment = Value
> End Set
> End Property
>
> <Description("Gets or sets the text of the column header."), _
> Category("General"), _
> DefaultValue("")> _
> Public Property HeaderText() As String
> Get
> Return m_HeaderText
> End Get
> Set(ByVal Value As String)
> m_HeaderText = Value
> End Set
> End Property
>
> <Description("Gets or sets the name used to map the column style to a
data
> member."), _
> Category("General"), _
> DefaultValue("")> _
> Public Property MappingName() As String
> Get
> Return m_MappingName
> End Get
> Set(ByVal Value As String)
> m_MappingName = Value
> End Set
> End Property
>
> <Description("Gets or sets the text that is displayed when the column
> contains a null reference (Nothing in Visual Basic)."), _
> Category("General"), _
> DefaultValue("")> _
> Public Property NullText() As String
> Get
> Return m_NullText
> End Get
> Set(ByVal Value As String)
> m_NullText = Value
> End Set
> End Property
>
> <Description("Gets or sets a value indicating whether the data in the
> column can be edited."), _
> Category("General"), _
> DefaultValue(True)> _
> Public Property [ReadOnly]() As Boolean
> Get
> Return m_ReadOnly
> End Get
> Set(ByVal Value As Boolean)
> m_ReadOnly = Value
> End Set
> End Property
>
> <Description("Gets or sets the width of the column."), _
> Category("General"), _
> DefaultValue(50)> _
> Public Property Width() As Integer
> Get
> Return m_Width
> End Get
> Set(ByVal Value As Integer)
> m_Width = Value
> End Set
> End Property
>
> <Description("Gets or sets weather the column should be displayed in the
> datagrid."), _
> Category("General"), _
> DefaultValue(True)> _
> Public Property Visible() As Boolean
> Get
> Return m_Visible
> End Get
> Set(ByVal Value As Boolean)
> m_Visible = Value
> End Set
> End Property
>
> Public WriteOnly Property Collection() As Columns
> Set(ByVal Value As Columns)
> m_Collection = Value
> End Set
> End Property
>
> <Browsable(True)> Public ReadOnly Property ColumnType() As ColumnTypes
> Get
> Return ColumnTypes.Base
> End Get
> End Property
>
> #End Region
>
> #Region " Methods"
>
> Protected Sub PropertyChanged()
> 'Check if the collection is a valid object if not during design time
you
> and up with a message 'Object is not set to an Instance' But Your Program
> Works
> 'By the way I am looking forward for the IsNot operator in VS 2005,
> because every time I forget the Not Operator and need to navigate back
> If Not m_Collection Is Nothing Then
> m_Collection.RaisePropertyChangedEvent()
> End If
> End Sub
>
> Public Overrides Function ToString() As String
> Return m_MappingName
> End Function
>
> #End Region
>
> Friend Class BaseColumnConverter
> Inherits ExpandableObjectConverter
>
> 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
> Dim mi As BaseColumn = CType(value, BaseColumn)
> Return String.Format("{0}", mi.MappingName)
> End Function
>
> Public Overloads Function CanConvertFrom(ByVal context As
> System.ComponentModel.ITypeDescriptorContext, ByVal sourceType As
> System.Type) As Boolean
>
> If (sourceType Is GetType(String)) Then
> Return True
> End If
>
> Return MyBase.CanConvertFrom(context, sourceType)
>
> End Function
>
> End Class
>
> End Class
>
> <Serializable(), TypeConverter(GetType(TextColumn.TextColumnConverter))> _
> Public Class TextColumn
> Inherits BaseColumn
>
> Private m_Format As String
>
> <Description("Gets or sets the character(s) that specify how text is
> formatted."), _
> Category("General"), _
> DefaultValue("")> _
> Public Property Format() As String
> Get
> Return m_Format
> End Get
> Set(ByVal Value As String)
> m_Format = Value
> End Set
> End Property
>
> <Browsable(True)> Public Shadows ReadOnly Property ColumnType() As
> ColumnTypes
> Get
> Return ColumnTypes.Text
> End Get
> End Property
>
> Friend Class TextColumnConverter
> Inherits BaseColumn.BaseColumnConverter
> 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
> Dim mi As TextColumn = CType(value, TextColumn)
> Return String.Format("{0}", mi.MappingName)
> End Function
> End Class
>
> End Class
>
> <Serializable(), TypeConverter(GetType(CheckColumn.CheckColumnConverter))>
_
> Public Class CheckColumn
> Inherits BaseColumn
>
> Protected m_TrueValue As Object
> Protected m_FalseValue As Object
>
> <Description("Gets or sets the actual value used when setting the value
of
> the column to true."), _
> Category("General"), _
> DefaultValue(False)> _
> Public Property TrueValue() As String
> Get
> Return CType(m_TrueValue, String)
> End Get
> Set(ByVal Value As String)
> m_TrueValue = Value
> End Set
> End Property
>
> <Description("Gets or sets the actual value used when setting the value
of
> the column to false."), _
> Category("General"), _
> DefaultValue(False)> _
> Public Property FalseValue() As String
> Get
> Return CType(m_FalseValue, String)
> End Get
> Set(ByVal Value As String)
> m_FalseValue = Value
> End Set
> End Property
>
> <Browsable(True)> Public Shadows ReadOnly Property ColumnType() As
> ColumnTypes
> Get
> Return ColumnTypes.Bool
> End Get
> End Property
>
> Friend Class CheckColumnConverter
> Inherits BaseColumn.BaseColumnConverter
> 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
> Dim mi As CheckColumn = CType(value, CheckColumn)
> Return String.Format("{0}", mi.MappingName)
> End Function
> End Class
>
> End Class
>
> #End Region
>
> #End Region
>
>
> "Michael" <laputa.yip@xxxxxxxxx> wrote in message
> news:%23SqLVMywFHA.3152@xxxxxxxxxxxxxxxxxxxxxxx
> > Dear all ..
> >
> > If I want to use develop a user control and declare a public property
> > which the type is System.Windows.Forms.GridTableStylesCollection
> >
> > For example :
> >
> > Public Class LookAndView
> > Inherits System.Windows.Forms.UserControl
> > Private _Collection As GridTableStylesCollection
> >
> >
> > Public Property Styles() As
> > System.Windows.Forms.GridTableStylesCollection
> > Get
> > Return _Collection
> > End Get
> > Set(ByVal Value As
System.Windows.Forms.GridTableStylesCollection)
> > _Collection = Value
> > End Set
> > End Property
> > emd class
> >
> > I want the properties Styles can edit in style collection editor during
> > in design mode. However, I find there some problem :
> > 1. Styles property show empty / nothing (I know the normal case is show
> > collection)
> > 2. When I click new in style collection editor and input some value into
> > properites. And then I click ok. During open the style collection
editor.
> > the member side still nothing.
> >
> >
> > Can any one help me to solve this problem ?
> >
> >
> > Thanks for your help
> >
> >
> > Michael VB developer
> >
>
>
.
- Follow-Ups:
- References:
- Prev by Date: Re: Creating a pictureBox on the main form from a thread
- Next by Date: Multiline Textbox Column Style For DataGrid Required!
- Previous by thread: Re: User style collection editor for GridTableStylesCollection
- Next by thread: Re: User style collection editor for GridTableStylesCollection
- Index(es):