Home Forums WinForms controls Xceed Grid for WinForms ExtendedProperties Reply To: ExtendedProperties

User (Old forums)
Member
Post count: 23064

Great!

So this one works for all objects. Is it right?
Imports System
Imports System.Collections

Public Class myExtendedProperties

Public Shared Function GetValue(ByVal element As Object) As Hashtable

‘the Tag MUST BE empty!
Dim h As Hashtable = element.Tag
If h Is Nothing Then
h = New Hashtable
element.Tag = h
End If
Return h

End Function

Public Shared Function GetValue(ByVal element As Object, ByVal key As String) As Object

Return GetValue(element)(key)

End Function

Public Shared Sub SetValue(ByVal element As Object, ByVal key As String, ByVal value As Object)

GetValue(element)(key) = value ‘allow NullValues

End Sub

End Class

================================================

‘set TextBox1 extended properties
myExtendedProperties.SetValue(TextBox1, “ID”, 55)
myExtendedProperties.SetValue(TextBox1, “Nome”, “TextBox1”)
myExtendedProperties.SetValue(TextBox1, “Tipo”, “Casella di testo”)

================================================

‘read TextBox1 extended properties
TextBox2.Text = “ID: ” & myExtendedProperties.GetValue(TextBox1, “ID”).ToString & vbCrLf
TextBox2.Text &= “Nome: ” & myExtendedProperties.GetValue(TextBox1, “Nome”).ToString & vbCrLf
TextBox2.Text &= “Tipo: ” & myExtendedProperties.GetValue(TextBox1, “Tipo”).ToString & vbCrLf

Imported from legacy forums. Posted by AndreaZ (had 281 views)