Runtime value to Attribute

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • caulagi@iiitb.ac.in

    #1

    Runtime value to Attribute

    Hello!

    I want to write -

    [Persistent, ReadOnly(form.I sFixedValue)]
    public double CycleTime
    {
    get { return cycletime; }
    }

    i.e. CycleTime should be readonly or otherwise depending on the value
    of form.IsFixedVal ue (IsFixedValue is a property of the form).

    But the above code doesn't work (of course). Is there a way to get it
    to work the way I want?

    TIA,

    Pradip

  • Ciaran O''Donnell

    #2
    RE: Runtime value to Attribute

    I think you need to provide the setter still otherwise it has to be readonly
    all the time.

    Ciaran O'Donnell

    "caulagi@iiitb. ac.in" wrote:
    Hello!
    >
    I want to write -
    >
    [Persistent, ReadOnly(form.I sFixedValue)]
    public double CycleTime
    {
    get { return cycletime; }
    }
    >
    i.e. CycleTime should be readonly or otherwise depending on the value
    of form.IsFixedVal ue (IsFixedValue is a property of the form).
    >
    But the above code doesn't work (of course). Is there a way to get it
    to work the way I want?
    >
    TIA,
    >
    Pradip
    >
    >

    Comment

    • caulagi@iiitb.ac.in

      #3
      Re: Runtime value to Attribute

      Yes, of course. Assuming I have a setter also in place, how can I make
      CycleTime readonly or otherwise, depending on form.IsFixedVal ue?

      TIA,
      Pradip

      Ciaran O''Donnell wrote:
      I think you need to provide the setter still otherwise it has to be readonly
      all the time.
      >
      Ciaran O'Donnell
      >
      "caulagi@iiitb. ac.in" wrote:
      >
      Hello!

      I want to write -

      [Persistent, ReadOnly(form.I sFixedValue)]
      public double CycleTime
      {
      get { return cycletime; }
      }

      i.e. CycleTime should be readonly or otherwise depending on the value
      of form.IsFixedVal ue (IsFixedValue is a property of the form).

      But the above code doesn't work (of course). Is there a way to get it
      to work the way I want?

      TIA,

      Pradip

      Comment

      • Marc Gravell

        #4
        Re: Runtime value to Attribute

        AFAIK you can't without some hacking in the component model and
        ICustomTypeDesc riptor (and this would only affect things like PropertyGrid -
        not compiled code). You can (and should), however, simply make the setter
        throw an exception (InvalidOperati onException) if it is used incorrectly.

        Marc


        Comment

        • Dave Sexton

          #5
          Re: Runtime value to Attribute

          Hi,

          And throwing an exception is usually fine in the designer because it's caught,
          and then displayed in a nice little message box :)

          --
          Dave Sexton

          "Marc Gravell" <marc.gravell@g mail.comwrote in message
          news:%23EI3KnwB HHA.3536@TK2MSF TNGP03.phx.gbl. ..
          AFAIK you can't without some hacking in the component model and
          ICustomTypeDesc riptor (and this would only affect things like PropertyGrid -
          not compiled code). You can (and should), however, simply make the setter
          throw an exception (InvalidOperati onException) if it is used incorrectly.
          >
          Marc
          >

          Comment

          Working...