Reference a text box in code

L

Lee

Hi All,

I have a form, with a text box on it.

I want to reference the contents of this text box in code using the Visual
Studio IDE, with Visual Basic.NET

the simple line

txtStatus.text = "Accepted"

does not work.

Anyone have any ideas where I should go for this?

Thanks

Lee
 
S

Scott L. Heim [MSFT]

Hi Lee,

It sounds like you may be new to either InfoPath or creating InfoPath
solutions with .NET - as such, I am going to include some additional links
that may be of interest.

InfoPath is completely data driven so you do not have programmatic access
to the controls themselves like you do in other applications. In order to
reference the text in a control, you have to drill down to the appropriate
XML node.

So in your example, if *all* you have done is create a new InfoPath VB.NET
solution and placed a text box on that form, the following code will
display the text in that control if you place this on the click event of a
button:

Dim objFieldNode As IXMLDOMNode
objFieldNode =
thisXDocument.DOM.selectSingleNode("my:myFields/my:field1")
thisXDocument.UI.Alert(objFieldNode.text)

Here is some additional information that you may find of interest (these
are in no particular order! <G>)

A beginner's guide to forms and form templates
http://office.microsoft.com/en-us/assistance/HA011559631033.aspx

Digitally signing data in an InfoPath Form
http://msdn.microsoft.com/library/en-us/odc_ip2003_ta/html/ODC_INFDigitallyS
igningData1.asp

InfoPath BLOG Site
http://blogs.msdn.com/infopath/

InfoPath Developer Site
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/ht
ml/odc_ancinfo.asp

InfoPath FAQ
http://www.microsoft.com/technet/prodtechnol/office/office2003/plan/inpthfaq
.mspx

InfoPath SDK
http://www.microsoft.com/downloads/details.aspx?FamilyId=351F0616-93AA-4FE8-
9238-D702F1BFBAB4&displaylang=en

InfoPath Technical FAQ
http://www.microsoft.com/technet/prodtechnol/office/office2003/plan/inpthfaq
.mspx#ECBAA

InfoPath Toolkit for VS.NET
http://www.microsoft.com/downloads/details.aspx?FamilyID=7e9ebc57-e115-4cac-
9986-a712e22879bb&DisplayLang=en

InfoPath Training
http://msdn.microsoft.com/office/understanding/infopath/toolsandcode/default
.aspx?pull=/library/en-us/odc_2003_ta/html/odc_landinfo03_tr.asp

MSDN XML DOM Documentation
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html
/e9da2722-7879-4e48-869c-7f16714e2824.asp

Understanding Fully Trusted Forms
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/
ipsdkUnderstandingFullyTrustedForms.asp

Using the Form Registration Tool
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/
ipsdkUsingTheFormRegistrationTool.asp

I hope this helps!

Best regards,

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
L

Lee

Great Scott,

That what I was looking for. Everything we want/need to do, infopath can do
but we've only just starting using it recently (over "smart" word documents
& acrobat forms) The intergration to sharepoint is key as well.

I'll go over the links you provided,

Thanks for your help.

Lee
 
S

Scott L. Heim [MSFT]

Hi Lee,

Glad to help! Let us know if you have any additional questions...

Take care,

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top