Hi,
I'm still in trouble with my collection which should refresh my control.
Here is my code extract.
custom Control class code :
....
private ColumnEventHandler HandlerColumnCollectionChanged;
....
/// in constructor
public CARListView()
{
this.HandlerColumnCollectionChanged = new
ColumnEventHandler(OnColumnCollectionChanged);
this.Columns.ColumnAmountChanged += this.HandlerColumnCollectionChanged;
}
....
[Category("Behavior")]
[Browsable(true)]
[Description("Column Collection")]
[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)]
[Editor(typeof(ColumnCollectionEditor),
typeof(System.Drawing.Design.UITypeEditor))]
public ColumnCollection Columns
{
get
{
if (this.m_columns == null)
{
this.m_columns = new ColumnCollection(this);
}
return this.m_columns;
}
}
....
public void OnColumnCollectionChanged(object Sender, ColumnEventArgs e)
{
this.Invalidate();
}
in my ColumnCollection class, i have the following code :
public event ColumnEventHandler ColumnAmountChanged;
public int Add(Column column)
{
if (column == null)
{
throw new System.ArgumentNullException("Column is null");
}
int index = this.List.Add(column);
this.RecalcWidthOfAllColumns();
this.OnColumnAmountChanged(new ColumnEventArgs(column, index,
ColumnEventType.ColumnAdded, null));
return index;
}
....
protected virtual void OnColumnAmountChanged(ColumnEventArgs e)
{
if (ColumnAmountChanged != null)
{
ColumnAmountChanged(this, e);
}
}
....
So everytime that a column is added, it should raise the event
ColumnAmountChanged. This event should be caught by
OnColumnCollectionChanged handler method, but it is not true.
So where could be the problem ?
thanks a lot,
Al.