Hi
I have a grid and I want to know in advance how wide to make the columns according to the text inside and a given font.
How can I calculate the width of a text in a given font (includes font name and sizeInPoints) , so that I will know how wide the columns must be .
Thanks.
Hi Mike
Thanks but I might not have explained my need properly. I wanted a fixed column width calculated in advance.
Anyway Matt gave me a satisfactory answer which works well
Hiya Matt
Thanks for the reply
This is just good enough for me and works very well
If you're referring to an IGrid within the Documents assembly, you might be able to get it by using an ICanvas object, which implements the IGraphics interface and has a GetStringWidth method, i.e.:
Report report = new Report();ICanvas canvas = report.AddSection().AddCanvas(); canvas.Font = new Infragistics.Documents.Graphics.Font("Arial", 14);float width = canvas.GetStringWidth("This is some text I want to measure");
If you're doing what Mike suggests, you might be able to use the width of the grid column, which you would have to convert to Points; there is an Infragistics.Documents.Utils.Converter.PixelsToPoints method you could use.
-Matt
Use the PerformAutoResize method on the column.