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
Madhur - 04 Nov 2006 19:34 GMT
> Hello,
>
[quoted text clipped - 10 lines]
>
> 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.
--
Madhur Ahuja
http://madhurahuja.blogspot.com
josepk@hotmail.com - 04 Nov 2006 21:11 GMT
OK - can you give me an example or syntax on how that is accomplished?
> jos...@hotmail.com wrote:
> > Hello,
[quoted text clipped - 18 lines]
>
> http://madhurahuja.blogspot.com
kap - 07 Nov 2006 20:45 GMT
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[i].text =
startdate.ToShortDateString();
SectionEndDateNodeList[i].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?
>
[quoted text clipped - 20 lines]
> >
> > http://madhurahuja.blogspot.com