读书人

为啥继承自DataGridViewColumn的自定义

发布时间: 2012-10-19 16:53:37 作者: rapoo

为什么继承自DataGridViewColumn的自定义Column总是无法保存属性值
public class TXDataGridViewNumericColumn : DataGridViewColumn
{
public TXDataGridViewNumericColumn() : base(new TXNumericCell())
{
this.InputType = NumericType.Integer;
this.CellTemplate=new TXNumericCell();
}

public override DataGridViewCell CellTemplate
{
get
{
return base.CellTemplate;
}
set
{
if (value != null &&
!value.GetType().IsAssignableFrom(typeof(TXNumericCell)))
{
throw new InvalidCastException("Must be a NumericCell");
}
base.CellTemplate = value;
}

}

private NumericType m_NumericType;


public enum NumericType
{
Decimal,
Integer,
PositiveDecimal,
NegativeDecimal,
PositiveInteger,
NegativeInteger
}


public NumericType InputType
{
get { return m_NumericType; }
set { m_NumericType = value; }
}
}

当在datagridview的列编辑器中选择列的InputType属性时(在设计模式时),其值不可以保存?请问哪里有问题?谢谢!

[解决办法]
shoud be a bug of your code

读书人网 >C#

热点推荐