Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Mar 01, 2021 4:39 am

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...

supermun
 
Posts: 24
Joined: Fri May 15, 2020 6:51 am

Mon Mar 01, 2021 11:31 am

Hello,

Thanks for your inquiry.

According to your code, I create a Word file containing a ComboBox, and then tried to get the selected value and display text of ComboBox, but did not reproduce your issue.
To help us investigate further, please provide the Word file you created that contains the ComboBox. Thanks in advance.

Sincerely,
Elena
E-iceblue support team
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Tue Mar 02, 2021 1:12 am

Hi Elena,

After loading attach file, I'll detach to multi docs with key word "#Phát hiện " and then get selected value of each combobox.

Thank you!

supermun
 
Posts: 24
Joined: Fri May 15, 2020 6:51 am

Tue Mar 02, 2021 10:37 am

Hello,

Thanks for your feedback.
I tested with the document you provided and indeed found that the selected value of combo boxes is null. I have posted this issue to our Dev team with the ticket SPIREDOC-5598 for further investigation. If there is any update, we will inform you immediately. Sorry for the inconvenience caused.

Sincerely,
Elena
E-iceblue support team
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Wed Mar 03, 2021 9:12 am

Hello,

Thanks for your information.

Is there any way to get TEXT of the paragraph that contain combobox? I tried .OwnerParagraph.Text but it return empty. :(

supermun
 
Posts: 24
Joined: Fri May 15, 2020 6:51 am

Wed Mar 03, 2021 10:00 am

Hello,

Thanks for your reply.
Please refer to the following code to get the text of the paragraph containing the combo box. Feel free to contact us if you have further questions.
Code: Select all
 
                  foreach (DocumentObject docObj in para.ChildObjects)
                    {
                        if (docObj is StructureDocumentTagInline)
                        {
                            if ((docObj as StructureDocumentTagInline).SDTProperties.SDTType == SdtType.ComboBox)
                            {
                                string t = (docObj.Owner as Paragraph).Text;
                            }
                        }
                    }

Sincerely,
Elena
E-iceblue support team
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Thu Mar 04, 2021 1:31 am

Hello,

I hoped your code can read display value of combobox but its cannot. it takes all the text before and after the combobox except display value.

I really need to get selected value or display value of combobox.

I have another solution: How can I check content controls using their tag then remove them in loaded document and keep all their text? In Word 365, I can remove content control without losing the text.

Could you please help me?

supermun
 
Posts: 24
Joined: Fri May 15, 2020 6:51 am

Thu Mar 04, 2021 8:39 am

Hi,

Thanks for your feedback.
We are very sorry that the paragraph text doesn't include the combo box value. Anyway, our Dev team will do further investigation on issue SPIREDOC-5598 and fix it. Once there is any good news, we will let you know.

As for removing the content control without losing the text, sorry that we don't support it at present. But I found that you can convert the Word file to TXT file (the code is as follows), it will exract the value of the combo box, you can try it on your side.
Code: Select all
            Document document = new Document();
            document.LoadFromFile(@"document.docx");

            String result = "Result-WordToText.txt";
            //Save the file.
            document.SaveToFile(result, FileFormat.Txt);


Sincerely,
Elena
E-iceblue support team
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Thu Mar 04, 2021 10:03 am

Dear Elena,

Thanks for your code.

If there is any information about issue SPIREDOC-5598, please email me ASAP. My email: tranvietlinh219@gmail.com

I look forward to hearing good news from you soon.

Thank you very much!

supermun
 
Posts: 24
Joined: Fri May 15, 2020 6:51 am

Fri Mar 05, 2021 7:45 am

Ok. If the issue SPIREDOC-5598 has any update, we will inform you immediately.

Sincerely,
Elena
E-iceblue support team
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Mon Mar 15, 2021 9:06 am

Elena.Zhang wrote:Ok. If the issue SPIREDOC-5598 has any update, we will inform you immediately.

Sincerely,
Elena
E-iceblue support team


Hello Elena,

Do you have any news about issue SPIREDOC-5598?

supermun
 
Posts: 24
Joined: Fri May 15, 2020 6:51 am

Mon Mar 15, 2021 9:28 am

Hello,

Thanks for your patience.
I just checked the status of your issue but found that it has not been resolved. I have urged our Dev team. We will inform you as soon as there is any good news. Apologize for the inconvenience caused.

Sincerely,
Elena
E-iceblue support team
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Fri Apr 02, 2021 3:34 am

Dear Elena,

Get selected value of combobox is an important and basic function.

It is not suitable to convert combobox to text file and then read file against

Please fix this issue soon....

Thank you very much!

supermun
 
Posts: 24
Joined: Fri May 15, 2020 6:51 am

Fri Apr 02, 2021 6:28 am

Hello,

Thanks for your patience.
I got news from the Dev team that the issue has been resolved. Now our Test team is doing further testing on the hotfix. Once the new version is available, we will inform you ASAP.

Sincerely,
Elena
E-iceblue support team
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Mon Apr 19, 2021 9:59 am

Hello,

Thanks for your patience!

Glad to inform you that we just released Spire.Doc Pack(Hot Fix) Version:9.4.12 which fixes your issue.

Please download the fix version from the following links to test.
Website link:
https://www.e-iceblue.com/Download/down ... t-now.html
Nuget link:
https://www.nuget.org/packages/Spire.Doc/9.4.12
Last edited by Andy.Zhou on Fri Apr 23, 2021 8:52 am, edited 1 time in total.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Return to Spire.Doc