This is a migrated thread and some comments may be shown as answers.

[Solved] How to enable a toolbar via code behind

3 Answers 211 Views
Editor
This is a migrated thread and some comments may be shown as answers.
ChrisS
Top achievements
Rank 1
ChrisS asked on 22 Feb 2008, 05:00 PM
By default, some of the toolbars are disabled within the toolsfile.  If a user has permission we enable one or more toolbars.  How do I enable a toolbar via code?  I have the following function:
 
    ' Name:         EnableToolbar  
    ' Purpose:      Enables the toolbar.  
    ' Parameters:   radEditor      - The rad editor.  
    '               strToolbarName - The name of the toolbar to enable.  
    ' Returns:      Nothing.  
    Public Shared Sub EnableToolbar(ByRef radEditor As RadEditor, ByVal strToolbarName As String)  
 
        Dim radEditorToolGroupCollection As EditorToolGroupCollection  
        Dim radEditorToolGroup As EditorToolGroup = Nothing 
        Dim l_bToolbarFound As Boolean = False 
 
        ' Read the collection of tools.  
        radEditorradEditorToolGroupCollection = radEditor.Tools  
 
        ' Iterate through the collection.  
        For Each radEditorToolGroup In radEditorToolGroupCollection  
            If (radEditorToolGroup.Tag = strToolbarName) Then  
                ' I have found the toolbar, but how do I enable it?  
            End If  
        Next  
    End Sub 

which identifies the correct toolbar but there is no enabled property to set.  Any ideas how to do this?

Many thanks

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 22 Feb 2008, 05:21 PM
Hi Chris,

Please, review the provided code in the Server-Side API example of RadEditor which could be helpful for your scenario.

Let me know if you need additional help.

Kind regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
ChrisS
Top achievements
Rank 1
answered on 22 Feb 2008, 05:29 PM
Dear Rumen,

Thank you for your reply.  In the example you have sent me you can:

Add a toolbar.
Remove a toolbar.
Add a new tool.
Add a new color.
Add a new paragraph.

Unfortunately it does not show me how to enable a toolbar within the code behind that has been disabled in the toolsfile.

Can you please have another look at my posting.

Many thanks
0
George
Telerik team
answered on 25 Feb 2008, 04:39 PM
Hi Chris,

Thank you for your code.

Unfortunately, we are not quite sure what you want to achieve, because RadEditor "Prometheus" does not provide the ability to disable or enable a tool group out of the box. We prepared a sample project based on your code which meets the following requirements:
  • go trough the RadEditor's ToolGroups into the ToolGroup Collection
  • check if the RadEditor ToolGroup's tag is the same as the strToolbarName and if it is - not remove the tool group from the editor's toolgroup collection.
Please, find the project attached and note that, to best reproduce your scenario, your ToolsFile.xml was needed.

I hope this helps.

Sincerely yours,
George
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Editor
Asked by
ChrisS
Top achievements
Rank 1
Answers by
Rumen
Telerik team
ChrisS
Top achievements
Rank 1
George
Telerik team
Share this question
or