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 / October 2005

Tip: Looking for answers? Try searching our database.

access drop-down list items using vb.net

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bleitner - 30 Oct 2005 03:41 GMT
I've filled a drop-down list box with a data connection and I want to access
those items in the list using vb.net managed code so I can assign the last
item in the list to a variable, any suggestion on how I can achieve this?

Thanks!
Bob
Franck Dauché - 30 Oct 2005 04:31 GMT
Hi Bob,

You need to access your secondary data source (used to fill your drop-down).

Here is C# code to access it (you will need to adapt to VB):

IXMLDOMDocument3 oSecondDoc =
(IXMLDOMDocument3)thisXDocument.DataObjects["tblTest"].DOM;
oSecondDoc.setProperty("SelectionNamespaces",
"xmlns:dfs=\"http://schemas.microsoft.com/office/infopath/2003/dataFormSolution\"
xmlns:d=\"http://schemas.microsoft.com/office/infopath/2003/ado/dataFields\"");
IXMLDOMNode oSecDocNode =
oSecondDoc.selectSingleNode("/dfs:myFields/dfs:dataFields");

to get to fldTest in that doc:
foreach (IXMLDOMNode oN in oSecDocNode.childNodes)
{
 if (oN.nodeType == DOMNodeType.NODE_ELEMENT)
 {
   IXMLDOMNode oField1 = oN.selectSingleNode("@fldTest");
 }
}

Hope that it gets you started....

Regards,

Franck Dauché

> I've filled a drop-down list box with a data connection and I want to access
> those items in the list using vb.net managed code so I can assign the last
> item in the list to a variable, any suggestion on how I can achieve this?
>
> Thanks!
> Bob
bleitner - 30 Oct 2005 15:51 GMT
Hi Frank,

Thank you for the reply, unfortunately I little experience with C# and am
having a hard time converting.  For instance, in the first line it looks like
you're declaring a variable, oSecondDoc to type IXMLDocument3 to a data
source "tblTest", but what's the "3" for?  Then in the second section it
looks like you're iterating through each of the child nodes of the returned
data connection testing for the list box items that match the field
"@fldTest", which is the field I would be looking for.  Does that sound
correct?

Thanks!
Bob

> Hi Bob,
>
[quoted text clipped - 31 lines]
> > Thanks!
> > Bob
Franck Dauché - 30 Oct 2005 20:20 GMT
Hi Bob,

You need to use a IXMLDOMDocument3 and not a IXMLDOMDocument because the
setProperty is available through a Document3 only.

I am not a VB person, but the VB.Net version would be something like:

Dim oSecondDoc As IXMLDOMDocument3 =
CType(thisXDocument.DataObjects("tblTest").DOM, IXMLDOMDocument3)
oSecondDoc.setProperty("SelectionNamespaces",
"xmlns:dfs='http://schemas.microsoft.com/office/infopath/2003/dataFormSolution' xmlns:d='http://schemas.microsoft.com/office/infopath/2003/ado/dataFields'")
Dim oSecDocNode As IXMLDOMNode =
oSecondDoc.selectSingleNode("/dfs:myFields/dfs:dataFields")

Dim oNode As IXMLDOMNode
Dim oField1 As IXMLDOMNode
For Each oNode In oSecDocNode.childNodes
   If (oNode.nodeType = DOMNodeType.NODE_ELEMENT) Then
       oField1 = oNode.selectSingleNode("@fldTest")
   End If
Next

Hope that it helps.

Regards,

Franck Dauché

> Hi Frank,
>
[quoted text clipped - 45 lines]
> > > Thanks!
> > > Bob
bleitner - 31 Oct 2005 04:27 GMT
you rock Frank!  it works great, thank you!

Bob

> Hi Bob,
>
[quoted text clipped - 73 lines]
> > > > Thanks!
> > > > Bob
 
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.