Home › Forums › WinForms controls › Xceed Grid for WinForms › ExtendedProperties › Reply To: ExtendedProperties
Well, no.
element should be of type Xceed.Grid.GridElement and not Object. GridElement has a Tag property, Object doesn’t. System.Windows.Forms.Control also has a Tag property, so you could support both GridElement and Control, like this:<code>Imports System
Imports System.Collections
Imports System.Windows.Forms
Imports Xceed.Grid
Public Class myExtendedProperties
Public Shared Function GetValue(ByVal element As GridElement) As Hashtable
Dim h As Hashtable = element.Tag
If h Is Nothing Then
‘ if the Tag is empty, create it
h = New Hashtable
element.Tag = h
End If
Return h
End Function
Public Shared Function GetValue(ByVal element As Control) As Hashtable
Dim h As Hashtable = element.Tag
If h Is Nothing Then
‘ if the Tag is empty, create it
h = New Hashtable
element.Tag = h
End If
Return h
End Function
Public Shared Function GetValue(ByVal element As GridElement, ByVal key As String) As Object
Return GetValue(element)(key)
End Function
Public Shared Function GetValue(ByVal element As Control, ByVal key As String) As Object
Return GetValue(element)(key)
End Function
Public Shared Sub SetValue(ByVal element As GridElement, ByVal key As String, ByVal value As Object)
GetValue(element)(key) = value
End Sub
Public Shared Sub SetValue(ByVal element As Control, ByVal key As String, ByVal value As Object)
GetValue(element)(key) = value
End Sub
End Class</code>
Imported from legacy forums. Posted by Tommy (had 145 views)