combit List & Label 29 - .NET Help
combit.Reporting Namespace / DrawDesignerObjectHandler Delegate


In This Topic
    DrawDesignerObjectHandler Delegate
    In This Topic

    After the user has edited the object, you are asked by List & Label to draw the object. The event DrawDesignerObject is triggered for this purpose. A Graphics object and the rectangle of the object are passed through EventArguments. Now, you can draw in the work area with the known GDI + methods. While doing so, access to the underlying object properties is naturally possible and useful. The sample listing shows the presentation of the graphic file selected above.

    Syntax
    'Declaration
     
    
    Public Delegate Sub DrawDesignerObjectHandler( _
       ByVal sender As Object, _
       ByVal e As DrawDesignerObjectEventArgs _
    ) 
    public delegate void DrawDesignerObjectHandler( 
       object sender,
       DrawDesignerObjectEventArgs e
    )
    public delegate void DrawDesignerObjectHandler( 
       Object^ sender,
       DrawDesignerObjectEventArgs^ e
    )

    Parameters

    sender
    e
    Remarks

    Due to a minor inconsistency, conversion of the font size should be carried out manually at the time of printing the text using the Graphics.DrawString, if necessary. The .NET framework calculates it internally as 1/10 inch. If millimeter (1/10) has been indicated as the metric unit (property Units), the size should be multiplied manually by 2.54:

    ...
    e.Graphics.DrawString("Hello world", new Font("Arial", 20F * 2.54F), new SolidBrush(Color.Black), e.ClipRectangle);
    ... 
    
    Example
    private void designerObject1_DrawDesignerObject(object sender, DrawDesignerObjectEventArgs e)
    {
         DesignerObject desobj = (DesignerObject) sender;
         if(desobj.ObjectProperties.Contains("imagefile"))
         {
              string imagefile = desobj.ObjectProperties["imagefile"].ToString();
              e.Graphics.DrawImage(new Bitmap(imagefile), e.ClipRectangle);
         }
    }
    
    Requirements

    Platforms: Windows 10 (Version 21H2 - 23H2), Windows 11 (21H2 - 22H2), Windows Server 2016 - 2022
    .NET: .NET Framework 4.8, .NET 6, .NET 7, .NET 8

    See Also