Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
235
How to stop button images from stretching?
posted

This is similar to the post: UltraWinGrid 8.3 Auto Row height and Cell Images, but my question is a little different.

I am trying to embed a wrench image into a button in the UltraGrid so users can click on it to make adjustments to the project.

My issue is, The image is stretched to the maximum, rather than kept at its original size. I do not want the image to stretch under any circumstances.

Here is my code:

private void ugPrograms_InitializeLayout(object sender, InitializeLayoutEventArgs e)
{
    /*
     * Other code here...
     */ 

    //// Program Edit
    //// Caption: " " (space)
    parent = sd._parentBand;
    column = sd._fldProgramEdit;
    ugSetImageButtonColumn(e, column);
    e.Layout.Bands[parent].Columns[column].Header.Caption = " ";
    e.Layout.Bands[parent].Columns[column].MinWidth = e.Layout.Bands[parent].Columns[column].MaxWidth = 25;
    e.Layout.Bands[parent].Columns[column].Header.VisiblePosition = headerPosition++;
    e.Layout.Bands[parent].Columns[column].AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;
}

public static void ugSetImageButtonColumn(InitializeLayoutEventArgs e, string column)
{
    e.Layout.Bands[sd._parentBand].Columns[column].AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;
    e.Layout.Bands[sd._parentBand].Columns[column].CellActivation = Activation.ActivateOnly;
    e.Layout.Bands[sd._parentBand].Columns[column].CellAppearance.ImageHAlign = sd._ugImageHAlign;
    e.Layout.Bands[sd._parentBand].Columns[column].CellAppearance.ImageVAlign = sd._ugImageVAlign;
    e.Layout.Bands[sd._parentBand].Columns[column].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Button;
    e.Layout.Bands[sd._parentBand].Columns[column].ButtonDisplayStyle = ButtonDisplayStyle.Always;
}

The attached photo is what it is supposed to look like at all times. The issue I have right now is that it stretches until it touches the edges of the cell.