Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / February 2007

Tip: Looking for answers? Try searching our database.

problem to update control when collection changed

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
--== Alain ==-- - 19 Feb 2007 16:21 GMT
Hi,

I have a collection property in my custom control like this one :

[Category("Behavior")]
[Browsable(true)]
[Description("Column Collection")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.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;
 }
}

it works very well, except one thing.

When the number of columns increase or decrease, it should redraw/update
the control, but nothing occurs.
I have to click somewhere on the form to update the control.

I tried to use eventhandlers, but where to use them when there is not
"set" in this property ?

I tried to add them in my ColumnCollection class where is the method to
add column and into the method to remove a column, but nothing worked.

Any ideas ?

thx.

Al.
Oliver Sturm - 21 Feb 2007 10:34 GMT
Hello ,

>I tried to use eventhandlers, but where to use them when there is not
>"set" in this property ?

You should derive your collection type from BindingList<T> (or implement
IBindingList if you're on .NET 1), there's an event available on that
class that you can use. Then you hook up to that event when you create the
collection and update your control when you detect changes.

>I tried to add them in my ColumnCollection class where is the method to
>add column and into the method to remove a column, but nothing worked.

Well, there's no real reason why that couldn't work, so you must have done
something wrong here. If you get the right notifications in the right
places and update your control, why wouldn't that work?

               Oliver Sturm
Signature

http://www.sturmnet.org/blog


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.