5 Answers, 1 is accepted
0
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:
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
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
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.
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik
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!