basquang™ on clouds

June 15, 2009

InfoPath: Drop-Down List Changed, Switch View

Filed under: InfoPath — basquang @ 5:11 AM

Web know, switch available in Button rule. Sometime, we need to switch view when InfoPath form data changed like Drop-Down List Changed Event. What’re We going to do?

We must implement FormEvents.ContextChanged and DropDown Changed. In FormEvents.ContextChanged we call


Here is my code

public void InternalStartup()
            EventManager.FormEvents.ContextChanged += new ContextChangedEventHandler(FormEvents_ContextChanged);
            EventManager.XmlEvents["/my:DoanhNghieps/my:loaiHinhHoatDong"].Changed += new XmlChangedEventHandler(loaiHinhHoatDong_Changed);

        public void FormEvents_ContextChanged(object sender, ContextChangedEventArgs e)
            if (canRedirect)
                canRedirect = false;
        private bool canRedirect = false;
        public void loaiHinhHoatDong_Changed(object sender, XmlEventArgs e)
            // Write your code here to change the main data source.
            canRedirect = true;           

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: