Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
WebHTMLEditor - Adding and Removing Buttons/Button Bars
posted

I think I might just need a little nudge here, but I can't seem to work out how to "clean up" the button bar in the HTMLEditor.

I can easily remove items with something like:

Dim htmledit As WebHtmlEditor = TryCast(sender, WebHtmlEditor)
htmledit.Toolbar.Items.Remove(ToolbarItemType.InsertFlash)

I have done this for many of the controls in the bar.  However, I'm still left with the toolbar section of the removed controls - so there is a blank toolbar in my rendered editor. 

Could you offer the code that would generate a toolbar similar to the one used in this forum?  Simple, one row, a few basic HTML edit functions (cut, past, bold, bullet).

Parents
  • 4960
    Verified Answer
    posted

    The easiest way to get rid of lots of toolbar buttons is to use the Quick Design.  In Visual Studio Design View, click the little right-facing arrow in the top right corner and from the smart tag that appears, choose "Quick Design."

    Choose "Toolbar" in the left pane, and then in the middle of the Quick Design form you should see a long, vertical list of toolbar items.  For example's sake, select the "Separator" item after "Paste" and then click the "Remove" button about 30-40 times until there are no more toolbar items after Paste.  When that is done, click the "Apply" button. What this should give you is a short toolbar with font-formatting buttons and copy, cut, paste buttons and that's it.

    The code for this you already have correct, this just saves you from having to repeat it over and over.  If, there is anything you don't want to see in your Toolbar after doing essentially that same code you've shown 30-40 times to clear out most of the buttons, those are probably called the "Separators" and "Double Separators". There will be several of them, if you're really keen on removing them through code you can use the Items.LastIndexOf(ToolbarItemType.Separator) method to get their index (repeating the same until all DoubleSeparators and RowSeparators are gone, too) and then Items.RemoveAt(thatIndex) to remove them one-by-one.  You can also Clear( ) the Items collection and add just the buttons you want to show-up.

    As a side note, if you (or the next person to read this thread) want no toolbar items at all then you can set the WebHtmlEditor1.Toolbar.CssClass property to "HideToolbar" and define this CSS class in your page's header:

    <head runat="server">
      
    <title>WebHtmlEditor(TM) Test Page</title>
      
    <style type="text/css">
          .HideToolbar { display: none; visibility: hidden; }
       </style>
    </
    head>

    HTH,

Reply Children
No Data