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;}
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.
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 KokkalagaddaAssociate Software Developer
Ok, now I have another issue...
Now the image is left- and top-aligned. Is there a way to make it centered?
I tried using this code and it does not seem to work:
e.Layout.Bands[0].Columns[column].CellButtonAppearance.ImageHAlign = Infragistics.Win.HAlign.Center;e.Layout.Bands[0].Columns[column].CellButtonAppearance.ImageVAlign = Infragistics.Win.VAlign.Middle;
I’m able to reproduce this issue using 16.1 and I will log it in our internal system to give it attention. I created case CAS-174996-Q9Y6J2 for this issue and will continue to send progress updates regarding the linked dev issue using this case number. Once I log this issue in our system, I will send its development id as an update.
I have logged “CellButtonAppearance.HAlign property has no effect on the relative position of the Image inside a cell” issue in our internal tracking system with a Development ID of 222148. The next step will be for a developer to review my investigation and confirm my findings or to offer a fix, or other resolution.
I will leave this case open and update you with any new information after the review. You can also continue to send updates to this case at any time.
You can view the status of the development issue connected to this case by selecting the "Development Issues" tab when viewing this case on the web site.
Please let me know if you need more information.
You can view the status of the development issue connected to this case by selecting the "Development Issues" tab when you log into your account at infragistics.com
Our developer looked into CellButtonAppearance.HAlign property has no effect on the relative position of the Image inside a cell issue and he confirmed that it’s not an issue and the Cell appearance is as expected in this case.
As long it’s a non-button cell CellApperance.ImageHAlign works. But if Image is not applied to the cell via an appearance then this image will be the value of the cell. In other words, it’s the cell content and not the decoration. As such, the Grid will treat it as cell text which can be aligned using TextHAlign on the appearance. So if the cell is displaying as button and if your image is the content of that cell then I recommend using TextHAlign property to align the image.
Hi Sahaja,
I am not able to find the "Development Issues" anywhere in the Infragistics website. Where can I find it?