Reputation: 123
I have a problem with a custom class. What happens is that it loses its value after the project is compiled. Can someone help me?
I have the following custom class:
public class DataGridViewTextBoxColumnCustom : System.Windows.Forms.DataGridViewTextBoxColumn
{
public bool EstaDisponibleParaFiltro { get; set; }
}
The problem is that in the form designer, when I add a column of type DataGridViewTextBoxCOlumnCustom
to the DataGridView control and set its property ThisAvailableParaFilter
to true
, the value always returns to false
. I hope you can give me a hand with this.
EDIT 1:
This is my custom class:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace Solucion.Presentacion.controles
{
public class DataGridViewTextBoxColumnCustom : System.Windows.Forms.DataGridViewTextBoxColumn
{
public bool EstaDisponibleParaFiltro { get; set; }
}
}
In the DataGridView
control I add one ColumnType
, DataGridViewTextBoxColumnCustom
, and set EstaDisponibleParaFiltro
property to true
:
But when I click Ok, the property always returns to false
. I need to fix it.
Upvotes: 1
Views: 95
Reputation: 123
Ok, i was able to fix the problem as follows:
[Browsable(true)] [DefaultValue(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public bool EstaDisponibleParaFiltro { get; set; }
public override object Clone() { var clone = (DataGridViewTextBoxColumnCustom)base.Clone(); clone.EstaDisponibleParaFiltro = this.EstaDisponibleParaFiltro; return clone; }
Upvotes: 1