Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Binding cutsom type value to Control

Binding cutsom type value to Control

Scheduled Pinned Locked Moved C#
databasewpfwcftutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ElCachubrey
    wrote on last edited by
    #1

    Hi all. Is exists way to binding cutsom type value to Control through databinding Example

    //My cutom type

    public class CLASSIFIED
    {
    public CLASSIFIED(double Val)
    {
    this._value = Val;
    }

        private double \_value;
    
        public static implicit operator CLASSIFIED(double Val)  
        {
            return new CLASSIFIED(Val);
        }
    
        public static implicit operator double(CLASSIFIED CLASSIFIED)  
        {
            return CLASSIFIED.\_value;
        }
    }
    
    //My Source provider
    class SourceProvider
    {
         CLASSIFIED Index {get{...} set{...}}
    }
    
    //My binding
    
    ...
    control.DataBindings.Add("EditValue", \_sourceProvider, "Index");
    //This way data binding not understand what binding value have double type!!!
    ...
    

    I know what i can do it through IFormatProvider interface like what : control.DataBindings.Add("EditValue", _sourceProvider, "Index", null, null, _myFormatProvider); But what about other way, derive my custom type from AN INTERFACE what DataBindings.Add(...) recognize and format my custom type value automaticaly???? public class CLASSIFIED : ISomeInterfceWhatDataBindingRecoginze { .... } } THANK!!!

    D 1 Reply Last reply
    0
    • E ElCachubrey

      Hi all. Is exists way to binding cutsom type value to Control through databinding Example

      //My cutom type

      public class CLASSIFIED
      {
      public CLASSIFIED(double Val)
      {
      this._value = Val;
      }

          private double \_value;
      
          public static implicit operator CLASSIFIED(double Val)  
          {
              return new CLASSIFIED(Val);
          }
      
          public static implicit operator double(CLASSIFIED CLASSIFIED)  
          {
              return CLASSIFIED.\_value;
          }
      }
      
      //My Source provider
      class SourceProvider
      {
           CLASSIFIED Index {get{...} set{...}}
      }
      
      //My binding
      
      ...
      control.DataBindings.Add("EditValue", \_sourceProvider, "Index");
      //This way data binding not understand what binding value have double type!!!
      ...
      

      I know what i can do it through IFormatProvider interface like what : control.DataBindings.Add("EditValue", _sourceProvider, "Index", null, null, _myFormatProvider); But what about other way, derive my custom type from AN INTERFACE what DataBindings.Add(...) recognize and format my custom type value automaticaly???? public class CLASSIFIED : ISomeInterfceWhatDataBindingRecoginze { .... } } THANK!!!

      D Offline
      D Offline
      Dave Sexton
      wrote on last edited by
      #2

      This[^] might be a good place to start looking.

      El'Cachubrey wrote:

      derive my custom type from AN INTERFACE

      IDatatSource[^] perhaps?

      But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson
      Because programming is an art, not a science. Marc Clifton
      I gave up when I couldn't spell "egg". Justine Allen

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups