I think i'd make use of the View's Tag property.
Set the Tag property to a string which is the 'id' field of a custom color in your database table.
Now you can query the database for the value of the custom color that corresponds to the View's Tag property and set the View's color property.
Both Activity and Panel objects have a
method:
GetAllViewsRecursive As IterableList
So once you have added all Views to your Activity you can then iterate all Views setting their color property if the View has a Tag property set and your table contains a corresponding custom color:
Dim TagValue As String
For Each v As View In Activity.GetAllViewsRecursive
If v.Tag<>Null AND v.Tag Is String Then
TagValue=v.Tag
If TagValue<>"" Then
' query the database for a custom color value whose 'id' equals TagValue and set the View's color property
End if
End If
Next
You can set the Tag property using the Designer or using code.
If a View is created using the Designer and you do not set a Tag property then the View's Tag property will be an empty string "".
If a View is created in code and you do not set a Tag property then the View's Tag property will be Null.
Create a code module containing subs (based on above code) to set the color of:
- A single View.
- All Views within an Activity.
- All Views within a Panel.
Now you can call these subs from any activity when required - at the end of your Activity_Create sub for example or after adding or modifying a View in code.
Martin.