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. custom control problem in design time

custom control problem in design time

Scheduled Pinned Locked Moved C#
helpdesign
4 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.
  • R Offline
    R Offline
    reza assar
    wrote on last edited by
    #1

    hi all i derived a class from DataGridViewTextBoxColumn named DataGridViewTextBoxColumn2 public class DataGridViewTextBoxColumn2 : DataGridViewTextBoxColumn { [DefaultValue(typeof(bool), "true")] public bool IsMandatoryColumn { get; set; } } in design time i click the Edit and change the value IsMandatoryColumn to true but when i return to edit form to chock if the property set to true or not surprisingly i find this property with the value of False please help me by the way i tried to implement a constructor and set the default value there and also tried to change the access method to old form of get{return ...} set{...=value} but the problem still persists pleeeeeeeeeeaaaaaaaaaaaaaaaaaase help me before i gonna crazy:mad::~:confused:

    R G 2 Replies Last reply
    0
    • R reza assar

      hi all i derived a class from DataGridViewTextBoxColumn named DataGridViewTextBoxColumn2 public class DataGridViewTextBoxColumn2 : DataGridViewTextBoxColumn { [DefaultValue(typeof(bool), "true")] public bool IsMandatoryColumn { get; set; } } in design time i click the Edit and change the value IsMandatoryColumn to true but when i return to edit form to chock if the property set to true or not surprisingly i find this property with the value of False please help me by the way i tried to implement a constructor and set the default value there and also tried to change the access method to old form of get{return ...} set{...=value} but the problem still persists pleeeeeeeeeeaaaaaaaaaaaaaaaaaase help me before i gonna crazy:mad::~:confused:

      R Offline
      R Offline
      reza assar
      wrote on last edited by
      #2

      hi the answer is Pretty simple public class DataGridViewTextBoxColumn2 : DataGridViewTextBoxColumn { [DefaultValue(typeof(bool), "false")] public bool IsMandatoryColumn { get; set; } public override object Clone() { DataGridViewTextBoxColumn2 test = (DataGridViewTextBoxColumn2)base.Clone(); test.IsMandatoryColumn = this.IsMandatoryColumn; return test; } } i love internet :laugh:

      1 Reply Last reply
      0
      • R reza assar

        hi all i derived a class from DataGridViewTextBoxColumn named DataGridViewTextBoxColumn2 public class DataGridViewTextBoxColumn2 : DataGridViewTextBoxColumn { [DefaultValue(typeof(bool), "true")] public bool IsMandatoryColumn { get; set; } } in design time i click the Edit and change the value IsMandatoryColumn to true but when i return to edit form to chock if the property set to true or not surprisingly i find this property with the value of False please help me by the way i tried to implement a constructor and set the default value there and also tried to change the access method to old form of get{return ...} set{...=value} but the problem still persists pleeeeeeeeeeaaaaaaaaaaaaaaaaaase help me before i gonna crazy:mad::~:confused:

        G Offline
        G Offline
        Gonzalo Cao
        wrote on last edited by
        #3

        The response you've got before is going to work, anyhow I think that you need to know why this won't work. Thing is that DefaultValue, prevents the form's designer from generating code for this property. So when you set the property as true, no value is generated and bool variables always initialize to false. That's what's giving you trouble.

        R 1 Reply Last reply
        0
        • G Gonzalo Cao

          The response you've got before is going to work, anyhow I think that you need to know why this won't work. Thing is that DefaultValue, prevents the form's designer from generating code for this property. So when you set the property as true, no value is generated and bool variables always initialize to false. That's what's giving you trouble.

          R Offline
          R Offline
          reza assar
          wrote on last edited by
          #4

          hi dear gonzalo NO i used DefaultValue intentionally to prevent designer from generating this line of code there is no different from having DefaultValue or not (i tried this senario several times) and it does not work. i seams designer will clone the object and copy all the changed properties and i have to copy may new property implicitly.

          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