Bind to image.imagelocation


Author
Message
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
I'm glad you got it working.  Many times, if you're getting exceptions from your property gets or sets at design-time because they contain code that only works at runtime, you can test the this.DesignMode property to determine whether the control is running or just in the designer.

Warning: that this.DesignMode property always returns false if you test it in the constructor of the control.  Once you're out of the constructor, it works fine, but as long as you're in the constructor, it hasn't been set, yet.

Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

I found my mistake BigGrin

Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

I tried to the code below but I cant drop my picturebox on form. Any ideas?

using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using MicroFour.StrataFrame.UI.Windows.Forms;
using JK.Framework.Base;

namespace JK.Framework.UI.Windows.Forms
{
    [Designer(typeof(System.Windows.Forms.Design.ControlDesigner))]
    public class ImageLocationPictureBox : System.Windows.Forms.PictureBox, INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
       
        public string ImageLocation2
        {
            get
            {
                return this.ImageLocation;
            }
            set
            {
                string lcImageLocation = this.ImageLocation;
                if (this.CheckPropertyChanged<string>("ImageLocation2", ref lcImageLocation, ref value))
                {
                    this.ImageLocation = value;
                    this.ImageLocation2Changed();
                }
            }
        }
        protected bool CheckPropertyChanged<T>(string propertyName, ref T oldValue, ref T newValue)
        {
            if (oldValue == null && newValue == null)
            {
                return false;
            }
            if ((oldValue == null && newValue != null) || !oldValue.Equals((T)newValue))
            {
                oldValue = newValue;
                FirePropertyChanged(propertyName);
                return true;
            }
            return false;
        }
        protected void FirePropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        private void ImageLocation2Changed()
        {
            this.FirePropertyChanged("ImageLocation2");
        }
    }
}

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
The problem is that the ImageLocation property does not have an ImageLocationChanged event.  You will need to subclass the PictureBox class and either add an event called ImageLocationChanged of type System.EventHandler or implement the INotifyPropertyChanged interface on the class and raise the PropertyChanged event when the ImageLocation changes.
Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

Anyway to bind to image.imagelocation?

I tried to set imagelocation and text to bindingproperty, but doesn't work.



Any ideas?



Thank you
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search