R
R.A.F.
Hi,
I have a custom control in which i have a property based on
CollectionBase class.
like the following one :
//------- XGrid.cs file --------------//
[Category("Behavior"),
Browsable(true),
Description("Column Collection"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ColumnsCollection Columns
{
get
{
if (this.m_Columns == null)
{
this.m_Columns = new ColumnsCollection(this);
}
return this.m_Columns;
}
}
protected internal virtual void OnColumnAdded(ColumnsCollectionEventArgs e)
{
this.Invalidate(); // <- this does not refresh the control on design
time :-(
if (ColumnAdded != null)
{
ColumnAdded(this, e);
}
}
//------- ColumnsCollection.cs file --------------//
this collection (named Columns) is as the following :
public class ColumnsCollection : CollectionBase
{
....
public ColumnsCollection(XGrid owner): base()
{
if (owner == null)
{
throw new ArgumentNullException("owner");
}
this.m_owner = owner;
}
public void Add(Column column)
{
if (column == null)
{
throw new System.ArgumentNullException("Column is null");
}
int index = this.List.Add(column);
this.RecalculateTotalWidth();
this.OnColumnAdded(new ColumnEventArgs(column, this.IndexOf(column),
ColumnEventType.ColumnAdded, null));
}
....
protected virtual void OnColumnAdded(ColumnEventArgs e)
{
this.m_owner.OnColumnAdded(e);
}
....
}
unfortunatelly, my control is not refresh automatically when i add a new
column to the Columns Property.
i have the same issue with removing column.
any idea ?
thanks a lot,
RAF
I have a custom control in which i have a property based on
CollectionBase class.
like the following one :
//------- XGrid.cs file --------------//
[Category("Behavior"),
Browsable(true),
Description("Column Collection"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ColumnsCollection Columns
{
get
{
if (this.m_Columns == null)
{
this.m_Columns = new ColumnsCollection(this);
}
return this.m_Columns;
}
}
protected internal virtual void OnColumnAdded(ColumnsCollectionEventArgs e)
{
this.Invalidate(); // <- this does not refresh the control on design
time :-(
if (ColumnAdded != null)
{
ColumnAdded(this, e);
}
}
//------- ColumnsCollection.cs file --------------//
this collection (named Columns) is as the following :
public class ColumnsCollection : CollectionBase
{
....
public ColumnsCollection(XGrid owner): base()
{
if (owner == null)
{
throw new ArgumentNullException("owner");
}
this.m_owner = owner;
}
public void Add(Column column)
{
if (column == null)
{
throw new System.ArgumentNullException("Column is null");
}
int index = this.List.Add(column);
this.RecalculateTotalWidth();
this.OnColumnAdded(new ColumnEventArgs(column, this.IndexOf(column),
ColumnEventType.ColumnAdded, null));
}
....
protected virtual void OnColumnAdded(ColumnEventArgs e)
{
this.m_owner.OnColumnAdded(e);
}
....
}
unfortunatelly, my control is not refresh automatically when i add a new
column to the Columns Property.
i have the same issue with removing column.
any idea ?
thanks a lot,
RAF