Control Property Refresh

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tomer

    #1

    Control Property Refresh

    I Created 3 Properties to my Control Mindate(retuns date) MaxDate ( return
    date )
    and a CustomList Property (allDates,Uptod ate...)
    when i choose from the list allDates for example the Mindate and MaxDate are
    set to the values i set in the method for the CustomList,
    The thing is that in Design time when i select allDates i don't see the
    changes on minDate and maxDate, only when i click on them(on the property
    box) they change to the currect date,
    How can i make them change immidiatly in Design time when i select allDates
    etc,,,,

    Thanks

    Tomer


  • Eric Cadwell

    #2
    Re: Control Property Refresh

    Try marking the property with the RefreshProperti esAttribute.

    Something like this:

    [RefreshProperti esAttribute(Ref reshProperties. All)]
    public listEnum CustomList
    {
    get { return listEnumValue; }
    set
    {
    if (listEnumValue != value)
    {
    listEnumValue = value;
    //reset other properties here
    }
    }
    }

    HTH;
    Eric Cadwell



    Comment

    • Tomer Ben

      #3
      Re: Control Property Refresh

      Hi Eric,
      I tried it and again, i can see the change only when i click on the
      property (mindate or maxdate)
      isn't there a way that the properties will change automaticly as i
      change the list values ?



      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • Eric Cadwell

        #4
        Re: Control Property Refresh

        Am I correct to say that when you set the custom list property, you
        internally set the mindate and maxdate?
        Is it your intention to have mindate and maxdate editable at design-time? If
        not, you can hide them from the property grid.

        Not sure what the issue is, as this code works for me:

        public enum CustomList{All, Past, Future}

        public class UserControl1 : System.Windows. Forms.UserContr ol
        {
        private CustomList customListValue = CustomList.All;
        private DateTime minDate = DateTime.MinVal ue;
        private DateTime maxDate = DateTime.MaxVal ue;

        [RefreshProperti esAttribute(Ref reshProperties. All)]
        public CustomList CustomList
        {
        get { return customListValue ; }
        set
        {
        if (customListValu e != value)
        {
        customListValue = value;

        //reset other properties here
        DateTime newMin = DateTime.MinVal ue;
        DateTime newMax = DateTime.MaxVal ue;
        switch (value)
        {
        case CustomList.Futu re:
        newMin = DateTime.Now;
        break;
        case CustomList.Past :
        newMax = DateTime.Now;
        break;
        }
        MinDate = newMin;
        MaxDate = newMax;
        }
        }
        }
        public DateTime MinDate
        {
        get { return minDate; }
        set { minDate = value; }
        }
        public DateTime MaxDate
        {
        get { return maxDate; }
        set { maxDate = value; }
        }
        }

        If I remove the RefreshProperti es attribute it stops updating, but with the
        attribute applied MinDate and MaxDate update accordingly in the designer
        when CustomList changes.

        HTH;
        Eric Cadwell



        Comment

        • Tomer Ben

          #5
          Re: Control Property Refresh

          GREAT ! this Works,
          I have another small question....:(
          If i want to go the other way arround.
          lets say to add "Custom: to my enum list and whenever the user will
          change the min/max date properties by himself the "Custom" will appear
          on top in the enum control list.

          Or - another idea..is there a way to hide the min/max properties from
          the developer and show the when he chooses
          "Custom".


          Tomer







          *** Sent via Developersdex http://www.developersdex.com ***
          Don't just participate in USENET...get rewarded for it!

          Comment

          • Eric Cadwell

            #6
            Re: Control Property Refresh

            Sounds like a bit more code.

            To change the value to custom you would just need to set conditions upon
            which a value is custom...

            For example:
            public DateTime MinDate
            {
            get { return minDate; }
            set
            {
            if (customListValu e != CustomList.Futu re && value != DateTime.MinVal ue)
            customListValue = CustomList.Cust om;

            minDate = value;
            }
            }

            The second route sounds possible, but it would require a lot more work.

            -Eric


            Comment

            Working...