Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / November 2005

Tip: Looking for answers? Try searching our database.

Managed code, drop-down-list

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim - 09 Nov 2005 15:38 GMT
Can anyone provide me a snippet of code where an item in a drop-down-list is
selected, probably via the onload event. For example, there is a drop-down of
the fifty states amd it's bound to a web service or sql query. How do have,
let's say Texas, selected on the drop-down when the infopath form loads.

Thanks in advance,
Jim
Franck Dauché - 09 Nov 2005 16:46 GMT
Hi Jim,

If you are storing IDs and displaying Names with your drop-down (let's say
Texas is 47), then what you have to do is to select your node in the schema
and set its value to 47.

Does it make sense?

Regards,

Franck Dauché

> Can anyone provide me a snippet of code where an item in a drop-down-list is
> selected, probably via the onload event. For example, there is a drop-down of
[quoted text clipped - 3 lines]
> Thanks in advance,
> Jim
Jim - 09 Nov 2005 16:55 GMT
It does make sense, thanks. If you have a snippet handy, I'd appreciate it.

Thanks again,
Jim

> Hi Jim,
>
[quoted text clipped - 15 lines]
> > Thanks in advance,
> > Jim
Franck Dauché - 09 Nov 2005 17:22 GMT
Sure.  Put the following C# code in the OnLoad:

IXMLDOMNode oField =
thisXDocument.DOM.selectSingleNode("/my:myFields/my:fieldLinkedToDropDown");  
//replace by your own XPath
oField.text = "47";

Regards,

Franck Dauché

> It does make sense, thanks. If you have a snippet handy, I'd appreciate it.
>
[quoted text clipped - 20 lines]
> > > Thanks in advance,
> > > Jim
Jim - 09 Nov 2005 17:32 GMT
Oh, the same way one would handle populating like a textbox! I'm sorry, I
already knew how to do that. Thanks a bunch Frank!

> Sure.  Put the following C# code in the OnLoad:
>
[quoted text clipped - 31 lines]
> > > > Thanks in advance,
> > > > Jim
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.