Click here to Skip to main content
15,922,696 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: adding date Pin
Robert Rohde9-Jan-05 20:04
Robert Rohde9-Jan-05 20:04 
GeneralRe: adding date Pin
GaryKoh10-Jan-05 3:15
GaryKoh10-Jan-05 3:15 
GeneralRe: adding date Pin
Robert Rohde10-Jan-05 3:21
Robert Rohde10-Jan-05 3:21 
GeneralRe: adding date Pin
Sebastien Lachance10-Jan-05 3:45
Sebastien Lachance10-Jan-05 3:45 
GeneralOpenFileDialog Pin
G-Viking9-Jan-05 9:38
G-Viking9-Jan-05 9:38 
GeneralRe: OpenFileDialog Pin
Robert Rohde9-Jan-05 20:07
Robert Rohde9-Jan-05 20:07 
GeneralRe: OpenFileDialog Pin
G-Viking9-Jan-05 22:19
G-Viking9-Jan-05 22:19 
GeneralCollectionEditor Pin
vocaris9-Jan-05 6:22
vocaris9-Jan-05 6:22 
Hello,

I'm new on this page and on VB.Net and want's to create an simple control. But for this I need a property with DataType is collection. In the collection I want to have an object with two properties ('Prop' and 'Value'). I have defined this property, but VB.Net doesn't save my edits in the built in CollectionEditor.

At the Control I have inserted the following code:
<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)> _<br />
  Public ReadOnly Property CustomProperties() As CustomPropertyCollection<br />
      Get<br />
         Return mvcolCustomPropertyCollection<br />
      End Get<br />
   End Property<br />


The definition of the CustomPropertyCollection and the object in the collection is:
Friend Class CustomPropertyConverter<br />
   ' Ohne den Konverter kann man nicht speichern<br />
   Inherits System.ComponentModel.TypeConverter<br />
<br />
   Public Overloads Overrides Function CanConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal destType As Type) As Boolean<br />
      If destType Is GetType(System.ComponentModel.Design.Serialization.InstanceDescriptor) Then<br />
         Return True<br />
      End If<br />
<br />
      Return MyBase.CanConvertTo(context, destType)<br />
   End Function<br />
<br />
   Public Overloads Overrides Function ConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, ByVal value As Object, ByVal destType As Type) As Object<br />
      If destType Is GetType(System.ComponentModel.Design.Serialization.InstanceDescriptor) Then<br />
         Dim cat As CustomProperty = DirectCast(value, CustomProperty)<br />
<br />
         Dim ci As System.Reflection.ConstructorInfo = GetType(CustomProperty).GetConstructor(System.Type.EmptyTypes)<br />
<br />
         Return New System.ComponentModel.Design.Serialization.InstanceDescriptor(ci, Nothing, False)<br />
      End If<br />
<br />
      Return MyBase.ConvertTo(context, culture, value, destType)<br />
   End Function<br />
End Class<br />
<br />
<System.ComponentModel.TypeConverter(GetType(CustomPropertyConverter))> _<br />
Public Class CustomProperty<br />
   Dim mvstrProperty As String<br />
   Dim mvstrValue As String<br />
<br />
   Public Property Prop() As String<br />
      Get<br />
         Prop = mvstrProperty<br />
      End Get<br />
      Set(ByVal pvstrProp As String)<br />
         mvstrProperty = pvstrProp<br />
      End Set<br />
   End Property<br />
<br />
   Public Property Value() As String<br />
      Get<br />
         Value = mvstrValue<br />
      End Get<br />
      Set(ByVal pvstrValue As String)<br />
         mvstrValue = pvstrValue<br />
      End Set<br />
   End Property<br />
End Class<br />
<br />
Public Class CustomPropertyCollection<br />
   Inherits CollectionBase<br />
<br />
   'Needed to implement the strongly-typed collection<br />
   Default Public Property Item(ByVal Index As Integer) As CustomProperty<br />
      Get<br />
         Return DirectCast(List.Item(Index), CustomProperty)<br />
      End Get<br />
      Set(ByVal Value As CustomProperty)<br />
         List.Item(Index) = Value<br />
      End Set<br />
   End Property<br />
<br />
   Public Function Add(ByVal Item As CustomProperty) As Integer<br />
      Return List.Add(Item)<br />
   End Function<br />
<br />
   Public Sub Insert(ByVal index As Integer, ByVal Item As CustomProperty)<br />
      If List.Contains(Item) Then<br />
         Throw New InvalidOperationException("Already in list.")<br />
      End If<br />
<br />
      List.Insert(index, Item)<br />
   End Sub<br />
<br />
   Public Function Contains(ByVal value As CustomProperty) As Boolean<br />
      Return List.Contains(value)<br />
   End Function<br />
<br />
   'Redraw the control<br />
   Protected Overrides Sub OnClearComplete()<br />
      MyBase.OnClearComplete()<br />
   End Sub<br />
<br />
   'Redraw the control and wire up button's redrawneeded event<br />
   Protected Overrides Sub OnInsertComplete(ByVal index As Integer, ByVal value As Object)<br />
      MyBase.OnInsertComplete(index, value)<br />
   End Sub<br />
<br />
   'Redraw the control<br />
   Protected Overrides Sub OnRemoveComplete(ByVal index As Integer, ByVal value As Object)<br />
      MyBase.OnRemoveComplete(index, value)<br />
   End Sub<br />
End Class<br />


The Part with the Converter I have seen in a sample for this page (outlookbartest). I don't know if I need it...

Please help me...
Vocaris
Generalrow addition Pin
Makniteasy8-Jan-05 21:55
Makniteasy8-Jan-05 21:55 
GeneralRe: row addition Pin
Briga9-Jan-05 21:52
Briga9-Jan-05 21:52 
GeneralRe: row addition Pin
Makniteasy10-Jan-05 20:57
Makniteasy10-Jan-05 20:57 
GeneralRe: row addition Pin
Briga11-Jan-05 23:51
Briga11-Jan-05 23:51 
Generaltool tip for list combo box Pin
casino japan8-Jan-05 21:21
casino japan8-Jan-05 21:21 
GeneralWise for windows Installer 2.02 Pin
paykani8-Jan-05 20:15
paykani8-Jan-05 20:15 
GeneralRe: Wise for windows Installer 2.02 Pin
casino japan8-Jan-05 21:19
casino japan8-Jan-05 21:19 
GeneralRe: Wise for windows Installer 2.02 Pin
Dave Kreskowiak10-Jan-05 3:31
mveDave Kreskowiak10-Jan-05 3:31 
Generalmdi child problem Pin
GaryKoh8-Jan-05 18:49
GaryKoh8-Jan-05 18:49 
GeneralRe: mdi child problem Pin
OICU8128-Jan-05 20:25
OICU8128-Jan-05 20:25 
GeneralRe: mdi child problem Pin
GaryKoh9-Jan-05 3:58
GaryKoh9-Jan-05 3:58 
GeneralRe: mdi child problem Pin
Robert Rohde9-Jan-05 4:58
Robert Rohde9-Jan-05 4:58 
GeneralRe: mdi child problem Pin
OICU8129-Jan-05 5:34
OICU8129-Jan-05 5:34 
GeneralRe: mdi child problem Pin
GaryKoh9-Jan-05 11:51
GaryKoh9-Jan-05 11:51 
GeneralDataGrid Rows Pin
8-Jan-05 17:04
suss8-Jan-05 17:04 
GeneralRe: DataGrid Rows Pin
Palestine_Guy8-Jan-05 20:47
Palestine_Guy8-Jan-05 20:47 
GeneralRe: DataGrid Rows Pin
Makniteasy8-Jan-05 21:13
Makniteasy8-Jan-05 21:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.