Property change does not refresh custom control

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
 
R

R.A.F.

Hi,

Unfortunatelly it does not help me.

Basically my problem is when i change this COlumns property, my control
does not update/refresh to show those changes... but if i change another
property, it refresh perfectly the control and shows changes performed
by Columns property :-(

so something must be wrong with this Columns property refreshing....but
what ?

RAF
hello,
This may help
http://www.vbdotnetheaven.com/UploadFile/scottlysle/CCAutoRefresh11012006154238PM/CCAutoRefresh.aspx

regards,
Husam Al-A'araj
www.aaraj.net

R.A.F. said:
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
 
R

R.A.F.

ok, i finally found how to refresh my control when a collection property
is updated and i do not see it as really LOGICAL. :-(

basically, i needed to create a special property editor for this
collection property and into the overridden function EditValue, i placed
control.refresh();

this force my control to redraw when i add or remove a column from this
collection property.

Why a simple invalidate() into the add or remove functions (from my
collection class) does not work ? this is a mystery for me.

Any idea ?

RAF

R.A.F. said:
Hi,

Unfortunatelly it does not help me.

Basically my problem is when i change this COlumns property, my control
does not update/refresh to show those changes... but if i change another
property, it refresh perfectly the control and shows changes performed
by Columns property :-(

so something must be wrong with this Columns property refreshing....but
what ?

RAF
hello,
This may help
http://www.vbdotnetheaven.com/UploadFile/scottlysle/CCAutoRefresh11012006154238PM/CCAutoRefresh.aspx


regards,
Husam Al-A'araj
www.aaraj.net

R.A.F. said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top