none
Word 2007 having issues adding adding values to combo list box. RRS feed

  • Question

  • I am trying to create a simple Word doc that when the user presses the button it takes the information in the boxes and tosses it into a template style paragraph.

    But my issue is that I have two combo list boxes as seen in the picture. I want to have two values in the drop down list as seen in the labels next to them but for the life of me I can't figure out how to do this in Word 2007.

    In Visual Studio this is much easier but I am work and need to snap this out for the folks at work.

    Is there an option that I can choose in the properties where I type in the values for each drop down or do I have to add them in at run time?

    http://i55.tinypic.com/fup53t.jpg 

    Thanks


    • Moved by Mike Feng Thursday, June 9, 2011 10:50 AM Word (From:Visual Basic General)
    Tuesday, June 7, 2011 3:17 PM

Answers

  • Hi SimpleOnline,

    You can use DropDownListContentControl, for more details, please take a look at this article on MSDN:

    http://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.dropdownlistcontentcontrol(VS.90).aspx

    which contains the code about adding items to combobox list.

    private Microsoft.Office.Tools.Word.DropDownListContentControl dropDownListControl1;
    
    private void AddDropDownListControlAtSelection()
    {
      this.Paragraphs[1].Range.InsertParagraphBefore();
      this.Paragraphs[1].Range.Select();
    
      dropDownListControl1 = this.Controls.AddDropDownListContentControl("dropDownListControl1");
      dropDownListControl1.DropDownListEntries.Add("Monday", "Monday", 0);
      dropDownListControl1.DropDownListEntries.Add("Tuesday", "Tuesday", 1);
      dropDownListControl1.DropDownListEntries.Add("Wednesday", "Wednesday", 2);
      dropDownListControl1.PlaceholderText = "Choose a day";
    }

    Hope this can give you the hint.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Bruce Song Thursday, July 7, 2011 12:20 PM
    Tuesday, June 14, 2011 1:39 PM

All replies

  •  Hi SimpleOnline,

    Welcome to the MSDN Forum.

    Is there an option that I can choose in the properties where I type in the values for each drop down or do I have to add them in at run time?

    The subItems of a combobox control is always added at runtime.

     I want to have two values in the drop down list as seen in the labels next to them but for the life of me I can't figure out how to do this in Word 2007.

     About this, you can ask in Word for developer forum. There are more experts in this aspect.

    Best regards,

     


    Mike Feng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, June 9, 2011 10:49 AM
  • Hi SimpleOnline,

    You can use DropDownListContentControl, for more details, please take a look at this article on MSDN:

    http://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.dropdownlistcontentcontrol(VS.90).aspx

    which contains the code about adding items to combobox list.

    private Microsoft.Office.Tools.Word.DropDownListContentControl dropDownListControl1;
    
    private void AddDropDownListControlAtSelection()
    {
      this.Paragraphs[1].Range.InsertParagraphBefore();
      this.Paragraphs[1].Range.Select();
    
      dropDownListControl1 = this.Controls.AddDropDownListContentControl("dropDownListControl1");
      dropDownListControl1.DropDownListEntries.Add("Monday", "Monday", 0);
      dropDownListControl1.DropDownListEntries.Add("Tuesday", "Tuesday", 1);
      dropDownListControl1.DropDownListEntries.Add("Wednesday", "Wednesday", 2);
      dropDownListControl1.PlaceholderText = "Choose a day";
    }

    Hope this can give you the hint.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Bruce Song Thursday, July 7, 2011 12:20 PM
    Tuesday, June 14, 2011 1:39 PM
  • Hi simpleonline1234

    Is the picture you show on a document surface, or in a UserForm?

    If on the document surface, which controls (menu commands) did you use to create the dropdowns?


    Cindy Meister, VSTO/Word MVP
    Thursday, June 16, 2011 1:03 PM
    Moderator
  • Hi SimpleOnline,

    What is the status of the problem on your side? If you still show any concern on your problem, just feel free to follow up.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, June 28, 2011 12:30 PM