Timezoneinformation from combobox - extra character added

Last post 03-08-2009 18:03 by Pat. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 03-08-2009 10:04

    • Pat
    • Top 500 Contributor
    • Joined on 02-26-2009
    • Posts 3

    Timezoneinformation from combobox - extra character added

    VS 2008 (visual basic), opennetcf 2.3.0.21

     I have no problems with using timezones and setting the zone/time etc. This is a different beastie.

     I use this code to load the timezones into a combobox (.net or .opennetcf combo makes no difference)

           tzc.Initialize()
            For Each tzi As OpenNETCF.WindowsCE.TimeZoneInformation In tzc
                TheIndex = cbTimeZones.Items.Add(tzi)
                If tzi.DisplayName = globals.time_zone Then
                    cbTimeZones.SelectedIndex = TheIndex
                    MyTimeZoneInformation = tzi
                End If
            Next

     

    Then after the user selects a timezone I use

                MyTimeZoneInformation = CType(cbTimeZones.SelectedItem, TimeZoneInformation)

    At this point MyTimeZoneInformation.DisplayName has a control character appended. Checking just prior to retrieving the SelectedItem shows no control character present.

     I then modified the combo loader to only load the tzi.DisplayName to check if its the casting thats the problem but the control character was still added to the end of the text.

    Then I switched to just "text" being loaded into the combo and retrieving the SelectedItem and there's no control character.

    So for some reason when a TimeZoneInformation object or even just a string from it is put into a combobox a control character is added to DisplayName.

    I also checked DaylightName using all the above methods and it never has a control character added to it.

    Bizzare!

  • 03-08-2009 12:47 In reply to

    • ctacke
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-27-2007
    • Indiana
    • Posts 2,254

    Re: Timezoneinformation from combobox - extra character added

     What exact character is it (what's the value of the char)?  Does it change?

  • 03-08-2009 18:03 In reply to

    • Pat
    • Top 500 Contributor
    • Joined on 02-26-2009
    • Posts 3

    Re: Timezoneinformation from combobox - extra character added

     I haven't actually figured that out. I switched to using StandardName. I have to store the text in a database so I can set the timezone the next time the device runs and the control characters in DIsplayName were messing me up big time. Its one of those WinCE devices with the protected OS and the timezone isn't written to the registry unless a special program is run.

    I have found out that DisplayName has control character(s) before going through a combobox but whatever it is seems to change when added to and extracted from the combobox. If I do this:

    MyTImeZoneState=DateTimeHelper( MyTimeZoneInformation)

           tzc.Initialize()
            For Each tzi As OpenNETCF.WindowsCE.TimeZoneInformation In tzc
                TheIndex = cbTimeZones.Items.Add(tzi)
                If tzi.DisplayName = MyTimeZoneInformation.DisplayName Then
                    cbTimeZones.SelectedIndex = TheIndex
                    MyTimeZoneInformation = tzi
                End If
            Next

     msgbox("'" + MyTImeZoneInformation +"'")

    Then I get a messagebox with the DisplayName surrounded by single quotes.

    MyTimeZoneInformation = CType(cbTimeZones.SelectedItem, TimeZoneInformation)

    At this point if I do 

     msgbox("'" + MyTImeZoneInformation +"'")

    I get only the first single quote and the msgbox text is terminated at the end of the DIsplayName regardless of what I add to the end of the message and trying to store the string with SQLite raises an exception (unless I use parameterized queries).

    If I strip all characters with an ascii value less than 32 from the string then msgbox shows the entire message and SQLite is happy with the update query without parameterization.

    Now, here's the part I just figured out: The control character(s) exist before going through the combobox and going through the combobox changes the character(s).

    When I compare the stripped string to the tzi.DisplayName in the combobox loading loop there is no match. If I strip tzi.DisplayName of control characters then compare then there is a match. If I store the unstripped tzi and compare it to MyTimeZoneInformation after casting the object from the combobox there is no match.

    Yet if I use StandardName or DaylightName in all of the above there is never any problem or need to strip control character.

     

Page 1 of 1 (3 items)