我有一个映射到 SQLDataAdapter 的数据网格,其中一行是一个整数,它是一个对应于字符串的 id。
我想在绘画功能中做的是:
protected override void Paint( Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight )
{
int id = ( ( int )this.PropertyDescriptor.GetValue( source.List[ rowNum ] ) );
int oldValue = id;
this.PropertyDescriptor.SetValue( source.List[ rowNum ], "Some Text" );// m_textDataMapping[ id ] );
base.Paint( g, bounds, source, rowNum, backBrush, foreBrush, alignToRight );
this.PropertyDescriptor.SetValue( source.List[ rowNum ], oldValue );
}
我在 this.PropertyDescriptor.SetValue 上收到关于无效参数异常的错误,我认为这是因为类型,如果我设置另一个整数,它运行正常。