RadDiagramRibbonBar, override New/Open/Save buttons actions

1 Answer 102 Views
Diagram, DiagramRibbonBar, DiagramToolBox
Marian
Top achievements
Rank 2
Iron
Iron
Iron
Marian asked on 26 Jul 2022, 10:47 PM

Hello,

how can I override New/Open/Save buttons actions in RadDiagramRibbonBar? I have found button properties, so I can add my event handlers. I have found also DisableDefaultSaveAction property. I set that property to true, but it disables only New and Save button actions, not Open button action. How can I disable also default Open button action? Also, why is it named '...SaveAction', when it disables also New action? I attached my test project for testing.

		private void MainForm_Load(object sender, EventArgs e)
		{
			//radDiagramRibbonBar1.buttonNew.Visibility = ElementVisibility.Collapsed;
			radDiagramRibbonBar1.DisableDefaultSaveAction = true;
			radDiagramRibbonBar1.buttonNew.Click += ButtonNew_Click;
			radDiagramRibbonBar1.buttonOpen.Click += ButtonOpen_Click;
			radDiagramRibbonBar1.buttonSave.Click += ButtonSave_Click;
		}

One more question, can I add my buttons / groups to ribbon bar also to main tab? I see I can add new tabs and buttons to them, is it possible to add also to main tab in a simple way? I don't know if I will need it, but it's interesting question.

I am starting to implement new editor based on diagram, so maybe next questions will follow, but I don't want to ask something I haven't studied and tested.

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 27 Jul 2022, 08:23 AM

Hi, Marian,

RadDiagramRibbonBar gives you public access to all of its tabs, groups and buttons/items. Thus, you can easily customize the ribbon UI according to your needs.

I have prepared a sample code snippet for your reference, demonstrating how to add custom groups/items or customize existing ones (e.g. change the save button with a custom one) in RadDiagramRibbonBar:

		private void MainForm_Load(object sender, EventArgs e)
		{ 
			RibbonTab tab = new RibbonTab();
			tab.Text = "My tab";
			this.radDiagramRibbonBar1.CommandTabs.Add(tab);

			RibbonTab existingTab = this.radDiagramRibbonBar1.CommandTabs[0] as RibbonTab;
			RadRibbonBarGroup group = new RadRibbonBarGroup();
			group.Text = "My group";
			RadButtonElement button = new RadButtonElement();
			button.Text = "Click";
			group.Items.Add(button);
			existingTab.Items.Add(group);

			RadButtonElement mySaveButton = new RadButtonElement();
			mySaveButton.Text = this.radDiagramRibbonBar1.buttonSave.Text;
			mySaveButton.Image = this.radDiagramRibbonBar1.buttonSave.Image;
			mySaveButton.SvgImage = this.radDiagramRibbonBar1.buttonSave.SvgImage;
			mySaveButton.TextImageRelation = this.radDiagramRibbonBar1.buttonSave.TextImageRelation;
			mySaveButton.Click += MySaveButton_Click;

			this.radDiagramRibbonBar1.groupGeneral.Items.Remove(this.radDiagramRibbonBar1.buttonSave);
			this.radDiagramRibbonBar1.groupGeneral.Items.Insert(2,mySaveButton);

		}

        private void MySaveButton_Click(object sender, EventArgs e)
        {
			RadMessageBox.Show("My save button is clicked!");
        }

The achieved result is illustrated below:

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


Marian
Top achievements
Rank 2
Iron
Iron
Iron
commented on 27 Jul 2022, 02:21 PM

Ok, thanks, so I have to remove old three buttons and add new ones. Because that DisableDefaultSaveAction property was working for New and Save button, but not for Open button. I can do it like this, but if there is that property, maybe you can consider to change its behavior also for Open button, I think this is generally needed functionality.
Dess | Tech Support Engineer, Principal
Telerik team
commented on 28 Jul 2022, 06:43 AM

Hello, Marian,    

Your feedback is greatly appreciated. I have discussed this topic with the team and logged it in our feedback portal by creating a public thread on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

I have also updated your Telerik points.

Tags
Diagram, DiagramRibbonBar, DiagramToolBox
Asked by
Marian
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or