Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

PictureEdit - How to display external images by providing links for them

$
0
0

The current example illustrates how to customize the default PictureEdit editor so that it can accept a path to a graphic file as an EditValue and display a corresponding image.

Question Comments

Added By: zheng zhong at: 11/23/2012 1:30:57 AM    

that way ,the file will be readed and readed again。
every time when shows the picture。
if I loading the file from website ,so slowly.

Added By: zheng zhong at: 11/23/2012 1:53:31 AM    

and
if you modify GraphicsEditViewInfo like this

 class GraphicsEditViewInfo : PictureEditViewInfo
        {
            public GraphicsEditViewInfo(RepositoryItem item) : base(item) { }

            public static Hashtable Images = new Hashtable();

            public override object EditValue
            {
                get
                {
                    return base.EditValue;
                }
                set
                {
                    if (value != null && value.GetType() == typeof(System.String))
                    {
                        if (Images.ContainsKey(value))
                        {

                            try
                            {
                                base.EditValue = Images[value];
                            }
                            catch
                            {
                                base.EditValue = Item.ErrorImage;
                            }
                        }
                        else
                        {

                            try
                            {
                            using (WebClient w = new System.Net.WebClient())
                            {
                                var b = w.OpenRead(value.ToString());
                                var bitmap = new Bitmap(b);
                                Images.Add(value, bitmap);
                            }
                           
                                base.EditValue = Images[value];
                            }
                            catch
                            {
                                base.EditValue = Item.ErrorImage;
                            }
                        }
                    }

                    else
                        base.EditValue = value;
                }
            }

        }

Added By: Martin Schönholzer CH at: 2/16/2015 5:48:54 AM    

Hi. I tried to use this tip to display external images. But in my case the RepositoryItemGraphicsEdit class is not found. What assembly contains this class and in what namespace?

Added By: Alisher (DevExpress Support) at: 2/16/2015 6:25:49 AM    

Hi Martin,

We don't have a RepositoryItemGraphicsEdit class in our WinForms library. This example illustrates how to create it. Please download it to see the implementation. 
Let us know of your results.

Added By: Martin Schönholzer CH at: 2/21/2015 7:16:53 AM    

It worked, thanks Alisher. ;)


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>