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

How to custom a diagramtoolbox item?

5 Answers 97 Views
Diagram, DiagramRibbonBar, DiagramToolBox
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 01 Apr 2016, 08:44 AM

Hi, I want to custom a diagramtoolbox item, how to do it with UI for WinForms?

waiting for answer, thanks

5 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 04 Apr 2016, 12:01 PM
Hello Jonathan,

Thank you for writing.

RadDiagramToolbox is a derivative of RadListView. Hence, if you need to add a custom item to it, please refer to the following code snippet:
public Form1()
{
    InitializeComponent();
    DiagramListViewDataItem item;
    item = new DiagramListViewDataItem() { Key = "My shape" };
    ElementShape shape = new RoundRectShape(15);
    item.Shape = shape;
    item.Group = this.radDiagramToolbox1.Groups[0];
    this.radDiagramToolbox1.Items.Add(item);
}

If it is not the exact requirement, please specify in details what is the exact goal that you are trying to achieve.

I hope this information helps. Should you have further questions I would be glad to help.

 Regards,
Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Jonathan
Top achievements
Rank 1
answered on 05 Apr 2016, 02:11 AM

Thanks for your reply~~

I want to custom some shapes like Ellipse,RoundRect that have no FillColor. Then, I can drag for use directly. Please see attachment.

0
Jonathan
Top achievements
Rank 1
answered on 05 Apr 2016, 07:19 AM
I also want to custom the color of the borders and so on. waiting for you, thanks~~
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 06 Apr 2016, 08:15 AM
Hello Jonathan,

Thank you for writing back. 

Here is demonstrated a sample code snippet how to customize the shape color and its thickness. Note that you can introduce any changes to the visual items in the RadDiagramToolbox by using the VisualItemFormatting which is inherited from RadListview.
public Form1()
{
    InitializeComponent();
 
    this.radDiagramToolbox1.VisualItemFormatting += radDiagramToolbox1_VisualItemFormatting;
    DiagramListViewDataItem item;
    item = new DiagramListViewDataItem() { Key = "My shape" };
    DonutShape shape = new DonutShape();
    shape.Thickness = 2;
    item.Shape = shape;
    item.Group = this.radDiagramToolbox1.Groups[0];
    this.radDiagramToolbox1.Items.Add(item);
}
 
private void radDiagramToolbox1_VisualItemFormatting(object sender, ListViewVisualItemEventArgs e)
{
    DiagramListViewDataItem dataItem = e.VisualItem.Data as DiagramListViewDataItem;
    if (dataItem != null)
    {
        DiagramListViewVisualItem el = e.VisualItem as DiagramListViewVisualItem;
        if (((DiagramListViewDataItem)e.VisualItem.Data).Key.ToString() == "My shape")
        {
            el.ShapeElement.BackColor = Color.Red;
        }
        else
        {
            el.ShapeElement.BackColor = Color.FromArgb(37, 160, 218);
        }
    }
}

I hope this information helps. If you have any additional questions, please let me know.

Regards,
Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Jonathan
Top achievements
Rank 1
answered on 20 Apr 2016, 03:32 AM

Thank you Dess!  Sorry reply so late. I think I got it. If any question else, I'll ask you.

Best regards!

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