Drawing rectangle on Diagram

Hi, I am using Version 5.1.0.51. I am trying to draw rectangles on the diagram. I am using following code please guide me how can I achieve this functionality.

Graphics g = this.diagram1.CreateGraphics();
g.DrawRectangle(new Pen(Color.Red), 0, 0, 100, 100);

or

g.DrawImage()

regards,

1 Reply

J. J.Nagarajan Syncfusion Team July 18, 2007 03:34 PM UTC

Hi Fahim,

If your intention is to draw rectangle on the diagram then you have to use the following code snippet

Syncfusion.Windows.Forms.Diagram.Rectangle nodeRect = new Syncfusion.Windows.Forms.Diagram.Rectangle(50, 100, 125, 75);
nodeRect.FillStyle.Color = Color.FromArgb(255, 223, 189);
nodeRect.LineStyle.LineColor = Color.Orange;
Syncfusion.Windows.Forms.Diagram.Label lbl = new Syncfusion.Windows.Forms.Diagram.Label(nodeRect,"Rectangle");
lbl.FontStyle.Size = 12;
lbl.FontStyle.Bold = true;
nodeRect.Labels.Add(lbl);
this.DiagramWebControl1.Model.AppendChild(nodeRect);

I have attached the sample that demonstrates this completely. You can download the sample from the following page.

http://websamples.syncfusion.com/samples/Diagram.Windows/F64323/main.htm

Please refer to the sample and let me know if you have any questions.

Thanks,
Nagaraj

Loader.
Up arrow icon