Re: Creating drop down dynamically using TemplateItemList

  •  03-24-2008, 12:08 PM

    Re: Creating drop down dynamically using TemplateItemList

    OK, great. That works for creating groups and line breaks. How do I now go about adding a custom drop down list using the TemplateItemsList property?
     
    Currently if I add an item to the TemplateItemsList property string, such as [SyntaxHighlighting], I of course just get a placeholder. I'm adding the control like so:
     

        private void AddCustomDropDown()
        {
            ToolControl control = this.uxEditor.ToolControls["SyntaxHighlighting"];
            if (control != null)
            {
                RichDropDownList syntaxHighlighter = new RichDropDownList(this.uxEditor);
                syntaxHighlighter.Width = Unit.Pixel(100);
                syntaxHighlighter.Attributes.Add("onchange", "$EX.highlightSyntax(this);");
                string[] languages = "cpp,c#,css,delphi,pascal,java,javascript,php,python,ruby,sql,vb,xml,html,xhtml,xslt".Split(',');

                syntaxHighlighter.Items.Add(new RichListItem("Highlight Syntax"));

                foreach (string language in languages)
                {
                    syntaxHighlighter.Items.Add(new RichListItem(language));
                }

                control.Control.Controls.Add(syntaxHighlighter);
            }
        }
     
    This adds my item, but you will notice the default item had to be added using syntaxHighlighter.Items.Add(new RichListItem("Highlight Syntax")); I would rather not do it this way, as the item now appears in my drop down list, unlike adding it the other way (XML method using a config file). Is there any way to get around this? Also, it doesn't display correctly in Firefox. As you can see from the image below, the drop down now appears to overlap the Size drop down.
     


    Any solution to this?
View Complete Thread