I have a button column that displays an image in the button. The image is very small, so the button could be fairly narrow, but it defaults to a much larger size. This looks bad and wastes space. How can I either:
1. Make the grid automatically size the column to the minimum width needed to show the image on the button?
2. Manually resize the column to the minimum width needed (the problem here is determining what that width should be, given an image width.)?
Yes, that's right, ifyou are creating an unbound column and not setting the Value on any cells in that column, then there's no data. My guess is that the PerformAutoResize is not account for the CellButtonAppearance image. So when you resize it, it's sizing based on just the column header. I was afraid that might be the case.
So what you would have to do is set the Width of the column based on the size of your image. You will have to add some padding for the button borders and you will probably want to add a little more padding so there's a little space around the image.
No I hadn't tried PerformAutoResize(). Didn't know it existed.
I tried and it resized it from 100 to 8, which is far too small.
This is a button column I added so there is no data associated with it (right?)
To create the column I went to the column collection and called Add() with a unique column name. Then I iniitalized it like
DelCol.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Button; DelCol.ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.Always; DelCol.Hidden = false; DelCol.Header.VisiblePosition = 0; DelCol.Header.Caption = ""; DelCol.CellButtonAppearance.Image = DelImg;
Have you tried calling PerformAutoResize on the column? If so, be sure to use the overload that takes an enum and specify AllRowsInBand.
If that doesn't work, what's the DataType of the column? Does this column have any data in it?