We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Diagram + WebPart problem

Hello,

Syncfusion looks very nice for us but we have a little problem with the diagram control.

We want to create the diagram in a webpart so we don't have a designer. I have found in the documentation an example on how to create diagram through the code but it is not compiling due to many errors because the example is for Windows not ASP.NET and especialy not for Web Part.

The code I used:
System.Web.UI.WebControls.Button btn = new System.Web.UI.WebControls.Button();
btn.Text = "asd";
this.Controls.Add(btn);
//Syncfusion.Web.UI.WebControls.Tools.TreeView tv = new Syncfusion.Web.UI.WebControls.Tools.TreeView();
Syncfusion.Web.UI.WebControls.Diagram.DiagramWebControl diag = new Syncfusion.Web.UI.WebControls.Diagram.DiagramWebControl();
Syncfusion.Windows.Forms.Diagram.Model model1 = new Syncfusion.Windows.Forms.Diagram.Model();
diag.Model = model1;
model1.Size = new SizeF(700, 700);
diag.height = 700;
diag.width = 700;
diag.BackColor = System.Drawing.Color.Aqua;


diag.EnableNodeSelection = true;
diag.EnableDragDrop = false;
this.Controls.Add(diag);

Syncfusion.Windows.Forms.Diagram.Rectangle r = new Syncfusion.Windows.Forms.Diagram.Rectangle(1, 1, 100, 100);
MeasureUnits units = MeasureUnits.Pixel;
((IUnitIndependent)r).SetPinPoint(new PointF(5,5), units);
r.EnableCentralPort = true;
model1.AppendChild(r);

The problem is that the diagram is shown (even with its background color) but the rectangle is not shown.. What could be wrong?

Thanks in advance!


1 Reply

AD Administrator Syncfusion Team March 11, 2008 08:45 AM UTC

Hi Blaze,

Thank you for your interest in Syncfusion Products.

It is possible to create a Diagram Web Control at run time and add nodes to it. Please find the code snippet that illustrates this:


DiagramWebControl diag = new DiagramWebControl();
diag.Height = 700;
diag.Width = 700;
diag.BackColor = System.Drawing.Color.AliceBlue;
diag.EnableNodeSelection = true;
diag.EnableDragDrop = false;
this.form1.Controls.Add(diag);
Syncfusion.Windows.Forms.Diagram.Rectangle r = new Syncfusion.Windows.Forms.Diagram.Rectangle(10, 10, 100, 100);
r.FillStyle.Color = Color.Blue;
r.EnableCentralPort = true;
diag.Model.AppendChild(r);


Please find the simple sample in the following link:

http://websamples.syncfusion.com/samples/Diagram.Web/6.1.0.34/F71967/main.htm

Please let me know if any concerns.

Regards,
Fathima


Loader.
Live Chat Icon For mobile
Up arrow icon