Dropdown to select Pictures - InfoPath Dev
in

InfoPath Dev

Dropdown to select Pictures

Last post 08-05-2010 12:23 PM by Potemkine. 26 replies.
Page 2 of 2 (27 items) < Previous 1 2
Sort Posts: Previous Next
  • 08-05-2010 10:32 AM In reply to

    • Toddg
    • Not Ranked
    • Joined on 08-05-2010
    • Posts 14

    Re: Dropdown to select Pictures

    I think I'm getting close.  Thanks again for all the help.

    The name of my drop down list is "dropdown" and the xpath is /my:myFields/my:Dropdown

    The name of my richtext field is "field240"

     Can you walk me through what to do next?  Where do I paste the xpath?

  • 08-05-2010 10:49 AM In reply to

    Re: Dropdown to select Pictures

    Ok with your Xpath replace the function field239 by this one

    public void field239_Changed(object sender, XmlEventArgs e)

    {

    // Write your code here to change the main data source.

     string MyURL = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:Dropdown",this.NamespaceManager).Value;
                if(MyURL!="")
                    this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:field240",this.NamespaceManager).InnerXml="<IMG xmlns=\"
    http://www.w3.org/1999/xhtml\" SRC=\"" + MyURL + "\" />";

    }

    Wnen you say The name of my richtext field is "field240", It mean that your xpath is /my:myFields/my:field240, I suppose that.

  • 08-05-2010 11:02 AM In reply to

    • Toddg
    • Not Ranked
    • Joined on 08-05-2010
    • Posts 14

    Re: Dropdown to select Pictures

    Yes richtext fields xpath is /my:myFields/my:field240.

  • 08-05-2010 11:10 AM In reply to

    • Toddg
    • Not Ranked
    • Joined on 08-05-2010
    • Posts 14

    Re: Dropdown to select Pictures

    I'm not getting any error messages but the images are also not showing up.

  • 08-05-2010 11:20 AM In reply to

    Re: Dropdown to select Pictures

    ok, Can you confirm that the value on the drop down list point to your file ?

    Can you show me an example ?

  • 08-05-2010 11:41 AM In reply to

    • Toddg
    • Not Ranked
    • Joined on 08-05-2010
    • Posts 14

    Re: Dropdown to select Pictures

     Here is an example of an entry in dropdown list properties.

    I entered lis box entries manually

    Value = Q:\!Todd\FORMS\Pics\1.jpg       (1.jpg is the name of the image)

    Display name = pic1

     

     

     

  • 08-05-2010 11:55 AM In reply to

    Re: Dropdown to select Pictures

    In you rich text field do you see something ? an empty image with red x?

     

  • 08-05-2010 11:59 AM In reply to

    Re: Dropdown to select Pictures

    ok I saw something ...

     string MyURL = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:Dropdown",this.NamespaceManager).Value;
                if(MyURL!="")
                    this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:field240",this.NamespaceManager).InnerXml="<IMG xmlns=\"http://www.w3.org/1999/xhtml\" SRC=\"" + MyURL + "\" />";

    You say me that the name of your dropdown field is my:Dropdown and I saw the name of your function is public void field239_Changed. There is something wrong.

    can you Right clic on your drop down, programming, Changed event, and put the code in this function

  • 08-05-2010 12:10 PM In reply to

    • Toddg
    • Not Ranked
    • Joined on 08-05-2010
    • Posts 14

    Re: Dropdown to select Pictures

    Here is a copy of the code as it stands right now.

    using Microsoft.Office.InfoPath;

    using System;

    using System.Windows.Forms;

    using System.Xml;

    using System.Xml.XPath;

    using mshtml;

    namespace ELM_Cost_Request_Form_Test_PICS1

    {

    public partial class FormCode

    {

    // Member variables are not supported in browser-enabled forms.

    // Instead, write and read these values from the FormState

    // dictionary using code such as the following:

    //

    // private object _memberVariable

    // {

    // get

    // {

    // return FormState["_memberVariable"];

    // }

    // set

    // {

    // FormState["_memberVariable"] = value;

    // }

    // }

    // NOTE: The following procedure is required by Microsoft Office InfoPath.

    // It can be modified using Microsoft Office InfoPath.

    public void InternalStartup()

    {

    EventManager.XmlEvents[
    "/my:myFields/my:field239"].Changed += new XmlChangedEventHandler(field239_Changed);EventManager.XmlEvents["/my:myFields/my:Dropdown"].Changed += new XmlChangedEventHandler(Dropdown_Changed);

    }

    public void field239_Changed(object sender, XmlEventArgs e)

    {

    // Write your code here to change the main data source.

    string MyURL = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:Dropdown", this.NamespaceManager).Value;

    if (MyURL != "")

    this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:field240", this.NamespaceManager).InnerXml = "<IMG xmlns=\"http://www.w3.org/1999/xhtml\" SRC=\"" + MyURL + "\" />";

    }

    public void Dropdown_Changed(object sender, XmlEventArgs e)

    {

    // Write your code here to change the main data source.

    }

    }

    }

  • 08-05-2010 12:14 PM In reply to

    Re: Dropdown to select Pictures

     

    using Microsoft.Office.InfoPath;

    using System;

    using System.Windows.Forms;

    using System.Xml;

    using System.Xml.XPath;

    using mshtml;

    namespace ELM_Cost_Request_Form_Test_PICS1

    {

    public partial class FormCode

    {

    // Member variables are not supported in browser-enabled forms.

    // Instead, write and read these values from the FormState

    // dictionary using code such as the following:

    //

    // private object _memberVariable

    // {

    // get

    // {

    // return FormState["_memberVariable"];

    // }

    // set

    // {

    // FormState["_memberVariable"] = value;

    // }

    // }

    // NOTE: The following procedure is required by Microsoft Office InfoPath.

    // It can be modified using Microsoft Office InfoPath.

    public void InternalStartup()

    {

    EventManager.XmlEvents[
    "/my:myFields/my:field239"].Changed += new XmlChangedEventHandler(field239_Changed);EventManager.XmlEvents["/my:myFields/my:Dropdown"].Changed += new XmlChangedEventHandler(Dropdown_Changed);

    }

    public void field239_Changed(object sender, XmlEventArgs e)

    {

    // Write your code here to change the main data source.

    }

    public void Dropdown_Changed(object sender, XmlEventArgs e)

    {

    string MyURL = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:Dropdown", this.NamespaceManager).Value;

    if (MyURL != "")

    this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:field240", this.NamespaceManager).InnerXml = "<IMG xmlns=\"http://www.w3.org/1999/xhtml\" SRC=\"" + MyURL + "\" />";

    // Write your code here to change the main data source.

    }

    }

    }

    Please, Let me know if it's work

  • 08-05-2010 12:15 PM In reply to

    • Toddg
    • Not Ranked
    • Joined on 08-05-2010
    • Posts 14

    Re: Dropdown to select Pictures

    I GOT IT.  It is working perfectly now.  Thank you sooooooo... much for all your help.  I would have never figured it out on my own.

  • 08-05-2010 12:23 PM In reply to

    Re: Dropdown to select Pictures

    Hello again,  I'm glad that I could help you with that

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