I have been trying to figure out how to get the selected value from a drop-down form field without any luck. I can get the selected index and when I try to use that index to get the text value I just get an empty string. I am sure I am not hitting the correct property, but any help would be greatly appreciated.
Below is my code. It is called from the "op.fields.modify" operation in the "e.operBeforeExecute" event.
The code that is commented out is the code in question:
/// <summary>
/// Gets the form field operation object.
/// </summary>
/// <param name="operation">The operation.</param>
/// <param name="newFieldValue">The new field value.</param>
/// <returns>The form field dobject.</returns>
private IPXC_FormField GetOperationFormFieldObject(IOperation operation, out string newFieldValue)
{
IPXC_FormField operationObject = null;
newFieldValue = null;
ICab parameters = null;
CoAUX_Cab root = null;
CoAUX_Cab input = null;
CoAUX_Cab inputValue = null;
CoAUX_Cab options = null;
CoAUX_Cab mask = null;
CoAUX_Cab optionsValue = null;
CoAUX_Cab optionsValueValue = null;
try
{
parameters = operation.Params;
root = parameters.Root;
input = root["Input"];
inputValue = input[0];
operationObject = (IPXC_FormField)inputValue.v;
// we got our field, now get the new field value
if (operationObject != null)
{
options = root["Options"];
mask = options["Mask"];
int maskValue = Convert.ToInt32(mask.v);
if ((maskValue & 0x100) == 0x100) // value
{
optionsValue = options["Value"];
if ((maskValue & 0x800) == 0x800) // selection
{
#warning TODO STEPHENS: how do I get the list values? i have the selected index of the list but can't seem to get the string value.
/*
optionsValueValue = optionsValue["Selection"];
int selectedIndex = Convert.ToInt32(optionsValueValue[0].v);
newFieldValue = options["OptList"][selectedIndex]["DispValue"].v.ToString();
*/
}
else
{
optionsValueValue = optionsValue["Value"];
newFieldValue = optionsValueValue.v.ToString();
}
}
else if ((maskValue & 0x400) == 0x400) // date-time
{
optionsValue = options["DateTimeValue"];
newFieldValue = DateTime.FromFileTimeUtc(Convert.ToInt64(optionsValue.v)).ToShortDateString();
}
}
}
catch
{
// swallow and return the default
}
finally
{
ReleaseComObject(optionsValueValue, "optionsValueValue");
ReleaseComObject(optionsValue, "optionsValue");
ReleaseComObject(mask, "mask");
ReleaseComObject(options, "options");
ReleaseComObject(inputValue, "inputValue");
ReleaseComObject(input, "input");
ReleaseComObject(root, "root");
ReleaseComObject(parameters, "parameters");
}
return operationObject;
}
Thank you,
Stephen
Unable to get the selected value from a drop-down form field.
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
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.
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.
-
- User
- Posts: 123
- Joined: Wed Mar 25, 2015 10:59 pm
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Unable to get the selected value from a drop-down form field.
Hello Stephen,
Here's how you can get the selected value:
Cheers,
Alex
Here's how you can get the selected value:
Code: Select all
{
pdfCtl.Doc.CoreDoc.CosDocument.LockDocument();
string str = ff.Value.GetString(); //IPXC_FormField ff
pdfCtl.Doc.CoreDoc.CosDocument.UnlockDocument();
}
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 123
- Joined: Wed Mar 25, 2015 10:59 pm
Re: Unable to get the selected value from a drop-down form field.
Thank you Alex.
I tried your code and the Value property of the form-field is null so I can't call GetString() off of it. I can call GetValueText(), but it is blank.
Any other ideas, or am I doing something wrong?
Also we are using version 6.0.319.0.
Thank you,
Stephen
I tried your code and the Value property of the form-field is null so I can't call GetString() off of it. I can call GetValueText(), but it is blank.
Any other ideas, or am I doing something wrong?
Also we are using version 6.0.319.0.
Thank you,
Stephen
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Unable to get the selected value from a drop-down form field.
Hello Stephen,
Please do test with the latest build - as 319 is rather old and the code Alex provided might have only been available in later versions.
Regards,
Stefan
Please do test with the latest build - as 319 is rather old and the code Alex provided might have only been available in later versions.
Regards,
Stefan
-
- User
- Posts: 123
- Joined: Wed Mar 25, 2015 10:59 pm
Re: Unable to get the selected value from a drop-down form field.
I agree Stefan, but unfortunately that is not an option for our company at this point. I will attempt to work around it.
Thank you,
Stephen
Thank you,
Stephen
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Unable to get the selected value from a drop-down form field.
Hello Stephen,
You will first need to check whether there is any selection in the list via the SelectedItemsCount property for example - if there is a selected value, then use the code that I gave you.
Cheers,
Alex
You will first need to check whether there is any selection in the list via the SelectedItemsCount property for example - if there is a selected value, then use the code that I gave you.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ