Profile Picture

GDI Drawing

Posted By Teddy Lambropoulos 14 Years Ago
Author
Message
Teddy Lambropoulos
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 20, Visits: 1

Hi, I have an NChartControl with an NGridSurface Series plotted on it. I am trying to use GDI drawing to create a rectangle on the surface of this plot. What I want is when I click the mouse on the plot, a rectangle is drawn. The problem I am having is that when I click on the NChart, I can not see the rectangle. I do not know if it is being drawn under the control or if it is being drawn at all. Here is the code I have so far:

Dim rect As Rectangle

Dim circlerect As Rectangle

Dim MoveFlag As Boolean

Dim DrawCircleFlag As Boolean

Dim DrawRectFlag As Boolean

Dim ClickX As Integer

Dim ClickY As Integer

 

Private Sub NChart_PColor_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NChart_PColor.MouseDown

MoveFlag = True

ClickX = e.X

ClickY = e.Y

If DrawRectFlag Then

rect.X = ClickX - CInt(rect.Width / 2)

rect.Y = ClickY - CInt(rect.Height / 2)

End If

NChart_PColor.Invalidate()

 

End Sub

 

 

Private Sub NChart_PColor_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles NChart_PColor.Paint

 

rect = New Rectangle(5, 5, 50, 90)

circlerect = New Rectangle(5, 5, 90, 90)

DrawRectFlag = True

 

Dim g As Graphics = e.Graphics

If DrawRectFlag And MoveFlag Then

g.DrawRectangle(Pens.Blue, rect)

End If

End Sub



Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
Hi Teddy,

To perform custom painting with GDI+ within the chart you have to use the INPaintCallback interface and the PaintCallback property of the chart control.

Please take a look at the following example in our Windows Forms demo application:

All Examples > Custom Painting > Custom Painting with GDI+



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic