custom control problem in design time
-
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 ofget{return ...} set{...=value}
but the problem still persists pleeeeeeeeeeaaaaaaaaaaaaaaaaaase help me before i gonna crazy:mad::~:confused: -
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 ofget{return ...} set{...=value}
but the problem still persists pleeeeeeeeeeaaaaaaaaaaaaaaaaaase help me before i gonna crazy:mad::~:confused: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: -
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 ofget{return ...} set{...=value}
but the problem still persists pleeeeeeeeeeaaaaaaaaaaaaaaaaaase help me before i gonna crazy:mad::~:confused: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.
-
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.
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.