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.

Parents
No Data
Reply
  • 6120
    Offline posted

    Hi Robert,

    To prevent the image from stretching, you can reduce the size of image so that it fits in all the rows of the Grid. Or alternatively you can set the MinRowHeight to image height and that way not stretch the image. For example you can do something like this in Grid’s InitializeLayout method.

    e.Layout.Override.MinRowHeight = 50//Set it to image height;

    Please let me know if I may be of further assistance.

    Sincerely,
    Sahaja Kokkalagadda
    Associate Software Developer

Children