RAD Posted May 6, 2008 Report Share Posted May 6, 2008 1. I set a chart background image programmtically. I then change it to another image. I then change it back to the first image but it seems the file is locked. I am assigning the imagebackground on the same chart object each time. I would have thought that each time a background image is changed then the file used to create it is released? 2. Also, when my code changes the image mode (from tile to watermark etc) nothing changes in the chart. I am using .bmp images. Quote Link to comment Share on other sites More sharing options...
Frank Posted May 6, 2008 Report Share Posted May 6, 2008 1) How are you passing the image to the chart background? as an image object? If so, we don't have the file and wi will not Dispose of the Image object since it was given by you and you may be using it somewhere else. 2) What code are you using to change this? Did you try calling Chart.Refresh()? Quote Link to comment Share on other sites More sharing options...
RAD Posted May 6, 2008 Author Report Share Posted May 6, 2008 Thanks for quick reply. 1) The code is ChartFX.WinForms.Adornments.ImageBackground i = new ChartFX.WinForms.Adornments.ImageBackground(<string location>);foreach (Chart c in Global.Charts.Values) {c.Background = null; c.Background = i; } Should I pass an Image object rather than a path? 2) Yes, I was just about (honest) to post back that .Refresh() fixes that. Apologies. Quote Link to comment Share on other sites More sharing options...
RAD Posted May 6, 2008 Author Report Share Posted May 6, 2008 I have not stated the problem very well - the original file remains locked after a new image is added. Quote Link to comment Share on other sites More sharing options...
Frank Posted May 6, 2008 Report Share Posted May 6, 2008 The following code should fix it: IDisposable bg = chart.Background as IDisposable; if (bg != null) bg.Dispose(); chart.BackGround = new .... Quote Link to comment Share on other sites More sharing options...
RAD Posted May 7, 2008 Author Report Share Posted May 7, 2008 Indeed it does, many thanks. Thanks for quick response as well. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.