List box problems in Infopath 2007

A

akash_waits

Hi,

I have a list box (not a drop down list box) which is getting populated
from the data from AD.

First, the top most row is empty.Is there any way to avoid that?

Second, selected default value is the last value in the list box. Can we
change that?

Third and last, i want to get the selected value of the list box. How to do
that?

I will be very thankful to you.

Akash Kansal.
 
P

Paresh

Hi,

 I have a list box (not a drop down list box) which is getting populated
from the data from AD.

First, the top most row is empty.Is there any way to avoid that?

Second, selected default value is the last value in the list box. Can we
change that?

Third and last, i want to get the selected value of the list box. How to do
that?

I will be very thankful to you.

 Akash Kansal.

Hi,

Please take a look at the following links:
http://groups.google.com/group/micr...&lnk=gst&q=set+default+value#1f1e5596939fe6c3
http://enterprise-solutions.swits.net/infopath2007/retrieve-value-infopath-form-field-code.htm

HTH.
Do let me know, in case you need any further info.

Regards,
Paresh
 
A

akash_waits

Hi Paresh,

The code and methods mentioned in the links are for drop down list box but i
want solution specifically for list box only not drop down list box. Problem
with list box is that its first options is empty and when the form will be
about to close, irrespective of the selected value, the last value in the
list box will be selected. And the "changed" event for the list box is
triggered only when the form is about to close. First line empty that is fine
but it is very neccessary for me to get the selected value of list box.
 
A

akash_waits

BTW Paresh i am using the following code to fill up the LIST BOX :

public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
//Sample array items to test ListBox population functionality
string[] arrayItems = new string[] {"ABC","DEF","GHI" };
try
{
if (arrayItems.Length > 0)
{
//RemoveFirstItem();
foreach (string name in arrayItems)
{
AddItem(name, name);
}

RemoveFirstItem();

}

}
catch (Exception ex)
{
}

}

private void RemoveFirstItem()
{
XPathNavigator DOM = this.CreateNavigator();
XPathNavigator group1 =
DOM.SelectSingleNode("/my:myFields/my:fteOptions", NamespaceManager);
XPathNavigator field1 =
DOM.SelectSingleNode("/my:myFields/my:fteOptions/my:eek:ption",
NamespaceManager);
field1.DeleteSelf();
}

private void AddItem(string itemId, string itemName)
{
XPathNavigator DOM = this.CreateNavigator();
XPathNavigator group1 =
DOM.SelectSingleNode("/my:myFields/my:fteOptions", NamespaceManager);
XPathNavigator field1 =
DOM.SelectSingleNode("/my:myFields/my:fteOptions/my:eek:ption",
NamespaceManager);
XPathNavigator newNode = field1.Clone();

newNode.MoveToAttribute("oName",
"http://schemas.microsoft.com/office/infopath/2007/myXSD/2005-02-05T06:37:44");
newNode.SetValue(itemName);

newNode.MoveToAttribute("oValue",
"http://schemas.microsoft.com/office/infopath/2007/myXSD/2005-02-05T06:37:44");
newNode.SetValue(itemId);

newNode.MoveToParent();
group1.AppendChild(newNode);
}

Is this the right code? this is filling up the list box with its first row
empty and changed event not working properly.

If no, can you give me the link or code snippet with the help of which i can
get my work done.
 

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