TimeZone - How to select the local one - InfoPath Dev
in

InfoPath Dev

TimeZone - How to select the local one

Last post 10-01-2010 08:19 AM by denfer06. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 09-29-2010 02:32 AM

    TimeZone - How to select the local one

     Hello

    I have a drop down list that list all TimeZone

    I want to select by default the local one

    How I can do that ?

    the form can be opened in different country.

    Note that my list contain the WindowsId that can be used once the local time zone has been found, to select the correct entry in the Drop down list

    Regards

     

     

  • 09-29-2010 06:54 AM In reply to

    Re: TimeZone - How to select the local one

    HI, a solution is to add some code on load of the form, and assign a value to your field if the form if new.

                     if (this.New)
                    {
                        System.Globalization.CultureInfo info = System.Globalization.CultureInfo.CurrentCulture;
                        this.MainDataSource.CreateNavigator().SelectSingleNode("").SetValue(info.LCID.ToString());
                    }

  • 09-30-2010 12:24 AM In reply to

    Re: TimeZone - How to select the local one

     Hello

    Thanks for the solution

    It's what I did :

    [InfoPathEventHandler(EventType = InfoPathEventType.OnLoad)]
            public void FormEvents_OnLoad(DocReturnEvent e)
            {            
                this.thisXDocument.DOM.selectSingleNode("/my:Job/my:Definition/@my:TimeZoneID").text = TimeZone.CurrentTimeZone.StandardName;
                this.thisXDocument.DOM.selectSingleNode("/my:Job/my:Definition/@my:HandoffTimeZoneID").text = TimeZone.CurrentTimeZone.StandardName;          
            }

    One more question

    I don't understand why I don't have "this.MainDataSource" available

    I'm Using InfoPath 2007 and I only have thisXDocument or thisApplication available

    Do you know Why ?

  • 10-01-2010 07:25 AM In reply to

    Re: TimeZone - How to select the local one

    Hi, I program on C# that's why I use  "this.MainDataSource", when you program on C# 2003 you have to use thisXDocument.DOM. I suggest you to make a condition if(thisXDocument.IsNew) to set your value, because if someone change the value, when i reoppen the form, the value will reinitialize.

  • 10-01-2010 07:47 AM In reply to

    Re: TimeZone - How to select the local one

    Hello

    Thanks for the tips

     I also develop on C# and when I select Tools-> Programming -> visual studio Tools for applications it opens the VS 2005 version

     I have both VS 2005 and 2008 installed on my computer

    Why I don't have the "this.MainDataSource" available ?

     

     

  • 10-01-2010 07:53 AM In reply to

    Re: TimeZone - How to select the local one

    In my knowledge, on Tools->form option--­> Programming - if you choose C#, you can use "this.MainDataSource", if you choose C#(Infopath 2003 compatible), you have thisXDocument.

  • 10-01-2010 08:19 AM In reply to

    Re: TimeZone - How to select the local one

     You get the trick, I have selected C#(Infopath 2003 compatible) this is why I got "thisXDocument" instead of "this.MainDataSource"

    Thanks for your help

Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.