How to draw a point on the screen (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Interacting with the map display > Working with the map display > How to draw a point on the screen (ArcObjects .NET 10.6 SDK)

How to draw a point on the screen


Drawing a point on the screen

The following code draws a point on the screen in the ActiveView where the mouse is clicked. The x,y coordinates come from a mousedown click event when the user interacts with the application. In this example, the point is not persisted on the screen but is removed after the next screen refresh.
[VB.NET]
Public Sub DrawPoint(ByVal activeView As ESRI.ArcGIS.Carto.IActiveView, ByVal x As System.Int32, ByVal y As System.Int32)
    If activeView Is Nothing Then
        Return
    End If
    
    Dim screenDisplay As ESRI.ArcGIS.Display.IScreenDisplay=activeView.ScreenDisplay
    
    ' Constant.
    screenDisplay.StartDrawing(screenDisplay.hDC, CShort(ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache))
    Dim simpleMarkerSymbol As ESRI.ArcGIS.Display.ISimpleMarkerSymbol=New ESRI.ArcGIS.Display.SimpleMarkerSymbolClass
    
    Dim symbol As ESRI.ArcGIS.Display.ISymbol=TryCast(simpleMarkerSymbol, ESRI.ArcGIS.Display.ISymbol) ' Dynamic cast.
    screenDisplay.SetSymbol(symbol)
    Dim displayTransformation As ESRI.ArcGIS.Display.IDisplayTransformation=screenDisplay.DisplayTransformation
    
    ' X and y are in device coordinates.
    Dim point As ESRI.ArcGIS.Geometry.IPoint=displayTransformation.ToMapPoint(x, y)
    
    screenDisplay.DrawPoint(point)
    screenDisplay.FinishDrawing()
End Sub
[C#]
public void DrawPoint(ESRI.ArcGIS.Carto.IActiveView activeView, System.Int32 x,
    System.Int32 y)
{
    if (activeView == null)
    {
        return ;
    }

    ESRI.ArcGIS.Display.IScreenDisplay screenDisplay=activeView.ScreenDisplay;

    // Constant.
    screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)
        ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit cast.
    ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol=new
        ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();

    ESRI.ArcGIS.Display.ISymbol symbol=simpleMarkerSymbol as
        ESRI.ArcGIS.Display.ISymbol; // Dynamic cast.
    screenDisplay.SetSymbol(symbol);
    ESRI.ArcGIS.Display.IDisplayTransformation displayTransformation =
        screenDisplay.DisplayTransformation;

    // X and y are in device coordinates.
    ESRI.ArcGIS.Geometry.IPoint point=displayTransformation.ToMapPoint(x, y);

    screenDisplay.DrawPoint(point);
    screenDisplay.FinishDrawing();
}


See Also:

How to draw a polyline on the screen
How to draw a polygon on the screen
How to draw a rectangle on the screen




Development licensing Deployment licensing
ArcGIS for Desktop Basic ArcGIS for Desktop Basic
ArcGIS for Desktop Standard ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced ArcGIS for Desktop Advanced
Engine Developer Kit Engine