Dear E-iceblue support team ,
When I load a document, how can I get selected value and selected display text of combo box in a paragraph?
I created a template:
Paragraph para = section1.AddParagraph();
para.AppendText("Select: ");
para.ApplyStyle(style_lv1.Name);
StructureDocumentTagInline sd0 = new StructureDocumentTagInline(document);
para.ChildObjects.Add(sd0);
sd0.SDTProperties.SDTType = SdtType.ComboBox;
sd0.SDTProperties.IsShowingPlaceHolder = true;
SdtComboBox cb0 = new SdtComboBox();
foreach (var item in ListValue)
{
SdtListItem Sdtitem = new SdtListItem(item.Text, item.Id.ToString());
cb0.ListItems.Add(Sdtitem);
}
cb0.ListItems.SelectedValue = cb0.ListItems[0];
sd0.SDTProperties.ControlProperties = cb0;
sd0.SDTProperties.Alias = "sdRuiRoTrongYeu";
TextRange rt0 = new TextRange(document);
rt0.Text = cb0.ListItems[0].DisplayText;
rt0.CharacterFormat.TextColor = Color.Red;
sd0.SDTContent.ChildObjects.Add(rt0);
But when I load file from user:
foreach (DocumentObject docObj in para.ChildObjects)
{
if (docObj is StructureDocumentTagInline)
{
if ((docObj as StructureDocumentTagInline).SDTProperties.SDTType == SdtType.ComboBox)
{
SdtComboBox combo = (docObj as StructureDocumentTagInline).SDTProperties.ControlProperties as SdtComboBox;
Console.WriteLine("Selected Value: " + combo.ListItems.SelectedValue);
Console.WriteLine("Selected Value: " + combo.ListItems.SelectedValue.Value);
Console.WriteLine("Text Value: " + combo.ListItems.SelectedValue.DisplayText);
Console.WriteLine("Last value: " + combo.LastValue);
}
}
}
but Selected Value of SdtComboBox alway is null.
I'm using freeDoc for .Net C#
Please help me ASAP...