Reference InfoPath 2007 Control?

J

josepk

Hello,

How does one go about referencing an InfoPath 2007 UI control via .NET
(C#) code? For example, if I wanted to programmatically populate the
contents of a Combo Box called "field1" by looping through a dataset?

In normal Visual Studio.NET 2005 development (e.g. Windows Forms) I
would just reference the control "field1" directly within the code.
However, this does not appear to be the case in InfoPath 2007 - I'm
sure it's a syntax issue - just not sure how to do it.

Thanks!

Joe
 
M

Madhur

Hello,

How does one go about referencing an InfoPath 2007 UI control via .NET
(C#) code? For example, if I wanted to programmatically populate the
contents of a Combo Box called "field1" by looping through a dataset?

In normal Visual Studio.NET 2005 development (e.g. Windows Forms) I
would just reference the control "field1" directly within the code.
However, this does not appear to be the case in InfoPath 2007 - I'm
sure it's a syntax issue - just not sure how to do it.

Thanks!

Joe

The controls in infopath are not referenced directly. Instead you set there
values by setting the values of nodes on xml. The control represents an
XmlNode object.
 
K

kap

Here is an example
Check out your sample.xml for the xml structure

public void UpdateForm(DateTime startdate, int interval)
{
DOMNodeList SectionStartDateNodeList =
thisXDocument.DOM.selectNodes("//cp:gtl/cp:linklist/cp:link/my:startdate");
DOMNodeList SectionEndDateNodeList =
thisXDocument.DOM.selectNodes("//cp:gtl/cp:linklist/cp:link/my:enddate");
int count = SectionStartDateNodeList.length;
string[] SectionList = new string[count];
if (startdate != null)
{

for (int i = 0; i < count; i++)
{

SectionStartDateNodeList.text =
startdate.ToShortDateString();
SectionEndDateNodeList.text =
startdate.AddDays(interval).ToShortDateString();
startdate = startdate.AddDays(interval + 1);
}


this.thisXDocument.View.ForceUpdate();
}
}


OK - can you give me an example or syntax on how that is accomplished?
 

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