Forum rules DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
I need to programmatically fill PDF forms with data retrieved from a database using the CORE API SDK. So far I can successfully fill all field types that I have needed to except the FFT_ComboBox field type.
Example code for FFT_RadioButton type is as follows and works fine:
// Cycle through widgets
for (uint i = 0; i < currentField.WidgetsCount; i++)
{
// Retrieve widget
IPXC_Annotation widget = currentField.Widget[i];
// Comapare with data value
if (widget.OnValue == item.Data)
{
// Set as active
currentField.CheckWidget(i, true);
break;
}
}
I need to do the same for FFT_ComboBox. Although I get the index for the option I cannot select the option.
string comboValue = string.Empty;
string comboLabel = string.Empty;
bool comboSelected = false;
// Loop through options
for (uint i = 0; i < currentField.OptCount; i++)
{
// Retrieve option
currentField.GetOpt(i, out comboValue, out comboLabel, out comboSelected);
// Comapare with data value
if (comboValue == item.Data)
{
// Set as selected
//currentField.SelectItem(i, true, true); //Does not work
break;
}
}
Can you please advise on code to select the combo option using the retrieved index. Assistance will be greatly appreciated.
Thanks for the response Alex. This confirmed that my code was correct. Found the reason it was not working is because I had to first set the default selected option to false before I could set the new selected item. Something like this...
string comboValue = string.Empty;
string comboLabel = string.Empty;
bool comboSelected = false;
// Loop through options
for (uint i = 0; i < currentField.OptCount; i++)
{
// Retrieve option
currentField.GetOpt(i, out comboValue, out comboLabel, out comboSelected);
// Clear default selection otherwise you cannot set new selection
if (comboSelected == true)
{
// Set as selected
currentField.SelectItem(i, false);
}
// Comapare with data value
if (comboValue == item.Data)
{
// Set as selected
currentField.SelectItem(i, true);
break;
}
}
Stuck on the FFT_ListBox type now. Implemented similar code to select items in a multiselect list box. The items are being checked and if debug the code currentField.SelectedItemsCount returns the correct number of items selected. When I save the document all the other field types are filled in correctly but there are no items selected in the multiselect list box. Can you please confirm that my code for the list type is correct, or whether I missed something?
case PXC_FormFieldType.FFT_ListBox:
//Loop through options and set selected
for (uint i = 0; i < currentField.OptCount; i++)
{
string listValue = string.Empty;
string listLabel = string.Empty;
bool listSelected = false;
// Retrieve option
currentField.GetOpt(i, out listValue, out listLabel, out listSelected);
// If it is the item we are looking for then set item selected
if (listValue == item.Data)
{
currentField.SelectItem(i, true);
}
}
Debug.WriteLine("Items selected: " + currentField.SelectedItemsCount); // can see the items selected increasing here
I have worked through the CORE API demo code. If I do similar code with programmatically creating a listbox and adding options, then setting the selected option works fine. It does not seem to want to work with a form that already has options. Here is the weird part though, if I programmatically add another option then I CAN set the selected options. Could this be a bug in the SDK?
// This does not work, no items selected in the list box
currentField.SelectItem(0, true);
currentField.SelectItem(1, true);
currentField.SelectItem(2, true);
// This works, all 3 items selected in the list box
currentField.InsertOptRecord("item9", "item9");
currentField.SelectItem(0, true);
currentField.SelectItem(1, true);
currentField.SelectItem(2, true);
Just following up on this. I had to work around this bug by removing all the entries in the list and then repopulating the list box, which then allows me to set the selected items. Ideally you shouldn't have alter the items in the list box to be able to set the selected items, so definitely something that should be looked at.
Sorry for the long reply - we'll be having the major V9 release in the couple of weeks - thus making final preparations and feature updates. Please bump this thread after the release is out - we'll definitely try to fix this issue.