I expected that setting the width of all IGridColumns of an IGrid to Infragistics.Documents.Report.AutoWidth.Instance would size the column widths according to the contained text. But it appears to render no differently than if I set all columns to the same relative width. There appears to be no IGrid property to get the columns after all the rows are added in case the 'AutoWidth' needs to be set for a column after the cell text is added. So is AutoWidth supposed to function?
I'm not entirely sure, but in my experience, AutoWidth is not related to the contents of the object it's related to the parent of that object. So it basically fills the remaining space in the parent object, I think.
I could be wrong about that, but I am fairly certain there is no way to measure text or the contents of a column and auto-size the width built-in to the Documents engine. What the UltraGridDocumentExporter does is measure the contents of the strings as they would be on-screen, and then gets that width and uses the PixelsToPoints method.
Mike, I appreciate your response. I was simply thiking that the AutoSize behavior worked as it was documented. According to the documentation, the Width property of the IGridColumn "Gets or sets the width of the column." and of the 4 types of objects it can take, the AutoSize setting is documented as "Represents a dynamic width. This class allows to set the width of an element according to its content". Since the width of the IGridColumn applies to the entire column, would have expected the behavior to autosize the column based on the contents of the cells in that column. I guess the documentation is wrong.
Mike, Unfortunately that is what the documentation says. So I decided to work around it. I have a generic print dialog using the document engine and print preview. My dialog supports various types of objects that I enumerate support of. I added a another object to print a generic DataTable and was trying to have the IGridColumn set to AutoSize - which did not work. So I added a an ExtendedProperty to each DataColumn of by DataTable to add a 'relwidth' property in the source that generates the data table. Then the generic print dialog handler can retrieve that property and use it for the RelativeWidth value. I simply set up the ExtendedProperty to realisti values for the data table that I want to print. I can also use other ExtendedProperties of the DataColumn to set up other IGridColumn properties as needed (or even cell alignment and formatting). So I worked around the issue. But I do believe that the IGridColumn is not dealing with AutoSize as documented. For what its worth, I have been using IQuickText for the cell contents instead of iText.
Hm, if that's what the documentation says, then I must be wrong. My only other guess is that the AutoWidth simply doesn't work for a complex object like a column because it has to interact with the grid and the rows.