How to add padding to Krypton Button

72 views Asked by At

I added a krypton button to a form, on the commonstate i added and image also set aligne to left-center before the text.

But i cannot finding padding option to push the image away from the left edge of the button.

Please, is there away i can do this?

1

There are 1 answers

1
Ruwiwidi On

Unfortunately it is not possible to add padding specifically to an image thorugh a property like Padding or ImagePadding.

If you want to, you can try overriding the button's OnPaint method and manually draw the image and text with your spacing.

Basic Example:

public class MyCustomKryptonButton : KryptonButton
{
    protected override void OnPaint(PaintEventArgs pevent)
    {
        base.OnPaint(pevent);
        
        int imgPaddingLeft = 10;
        int imgPaddingTop = 10;
        
        if (this.Values.Image != null)
        {
            pevent.Graphics.DrawImage(this.Values.Image, new Point(imgPaddingLeft, imgPaddingTop));
        }
    }
}