Imports Infragistics.Win
Imports Infragistics.Win.UltraWinSchedule
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Get a list of the time zones in this computer's registry
Dim timeZoneList As ArrayList = Infragistics.Win.Utilities.GetTimeZones()
' Obtain a reference to the TimeZoneInfo object that represents
' the "Pacific Standard Time" time zone
Dim tzi As TimeZoneInfo = Nothing
Dim tziTemp As TimeZoneInfo = Nothing
For Each tziTemp In timeZoneList
If tziTemp.StandardName = "Pacific Standard Time" Then
tzi = tziTemp
Exit For
End If
Next
' If we could not get the TimeZoneInfo object for Pacific
' Standard Time, return
If tzi Is Nothing Then Return
' Set the AdditionalTimeZoneUtcOffset property of the
' UltraDayView control to the UtcOffset property of
' the TimeZoneInfo object we obtained above
Me.UltraDayView1.AdditionalTimeZoneUtcOffset = tzi.UtcOffset
' Set the AdditionalTimeZoneLabel property of the
' UltraDayView control to the acronym for the standard
' name of the TimeZoneInfo object we obtained above
Me.UltraDayView1.AdditionalTimeZoneLabel = Me.GetAcronym(tzi.StandardName)
' Set the CurrentTimeZoneLabel property of the
' UltraDayView control to the acronym for the current
' time zone's StandardName
Me.UltraDayView1.CurrentTimeZoneLabel = Me.GetAcronym(TimeZone.CurrentTimeZone.StandardName)
' Set the AdditionalTimeZoneVisible property of the
' UltraDayView control to true
Me.UltraDayView1.AdditionalTimeZoneVisible = True
End Sub
' Returns the acronym for the specified string, or an empty
' string if there are no spaces in the specified string
Private Function GetAcronym(ByVal text As String) As String
If text Is Nothing Or text.Length = 0 Then Return String.Empty
' Split the string on every space character
Dim splitChar As String = " "
Dim words As String() = text.Split(splitChar.ToCharArray())
' Iterate the array of substrings, and accumulate
' the first character of each one
Dim retVal As String = String.Empty
Dim i As Integer
For i = 0 To words.GetLength(0) - 1
retVal += words(i).Substring(0, 1)
Next
' Make the result uppercase, and return it
Return retVal.ToUpper()
End Function