Infragistics 15.2 WorksheetImage.SetBoundsInTwips compilation error

喜欢而已 提交于 2019-12-12 03:19:55

问题


I have the following code

System.Drawing.Image logo = ... (getting logo)
WorksheetImage worksheetImage = new WorksheetImage(logo);
worksheetImage.PositioningMode = ShapePositioningMode.DontMoveOrSizeWithCells;

// Original code (works with Infragistics 13.1)
Rectangle imageRect = new Rectangle(100, 100, 10 * logo.Width, 10 * logo.Height);
worksheetImage.SetBoundsInTwips(worksheet, imageRect, true); // Breaks here

The following code works with Infragistics 13.1 library. However, when migrating to 15.2, compiler spits out an error:

The best overloaded method match for 'Infragistics.Documents.Excel.WorksheetImage.SetBoundsInTwips(Infragistics.Documents.Excel.Worksheet, System.Windows.Rect, bool)' has some invalid arguments

Argument 2: cannot convert from 'System.Drawing.Rectangle' to 'System.Windows.Rect'

So basically it says that the second argument should be of type System.Windows.Rect and not System.Drawing.Rectangle. The information here indicates that the type I am passing in is correct, but compiler disagrees. Why is that the case?


回答1:


The Infragistics WindowsForms Excel engine's SetBoundsInTwips method indeed uses System.Drawing.Rect as one of its parameters. However the WPF implementation uses System.Windows.Rect. If this call doesn't compile then you are probably using the WPF library. Please check the references of your project and see if they use the WPF Assembly (InfragisticsWPF4.Documents.Excel.v15.2) and substitute it with the WF one (Infragistics4.Documents.Excel.v15.2).




回答2:


So the issue has been resolved - apparently the method SetBoundsInTwips in WPF in Infragistics 15.2 takes Rect as oppose to Rectangle in 13.1, so changing Rectangle to Rect did the job.



来源:https://stackoverflow.com/questions/34143214/infragistics-15-2-worksheetimage-setboundsintwips-compilation-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!