A
Adam Sandler
I have a class with a method which returns a panel. The panel was not
created with the visual editor, I coded it by hand -- because some of
the content on the panel can be dynamic and thus I chose to do it that
way.
At any rate, I have an event handler for a button which instantiates
an object of that class I mentioned and calls the method to return the
panel. I put the panel on form1 like so:
// it's really not called 'Class', I changed the name to simplify the
post
Class myClass = new Class();
this.Controls.Add(myClass.getPanel());
Everything up to this point works.
If that event handler is ever called again (i.e., n times; more than
once), due to information which changed and needs to be displayed on
the custom panel, the result at runtime is the panel doesn't appear to
update.
I've put some breakpoints in and debugged. The information which
needs to be updated on the panel is indeed updating as viewed with the
debugger breaks. But when this.Controls.Add(myClass.getPanel()); is
called, the old information remains on the form.
Where I'm really lost is the new instance of the panel reflects the
updated information but when it's added to the form, only the first
instance of the panel, with the initial information, is ever
displayed. How can I get the newest panel on the form? I was
thinking about making a call to remove but I'm not sure that would
work when the panel is being created at runtime. Suggestions are
greatly appreciated.
Thanks!
created with the visual editor, I coded it by hand -- because some of
the content on the panel can be dynamic and thus I chose to do it that
way.
At any rate, I have an event handler for a button which instantiates
an object of that class I mentioned and calls the method to return the
panel. I put the panel on form1 like so:
// it's really not called 'Class', I changed the name to simplify the
post
Class myClass = new Class();
this.Controls.Add(myClass.getPanel());
Everything up to this point works.
If that event handler is ever called again (i.e., n times; more than
once), due to information which changed and needs to be displayed on
the custom panel, the result at runtime is the panel doesn't appear to
update.
I've put some breakpoints in and debugged. The information which
needs to be updated on the panel is indeed updating as viewed with the
debugger breaks. But when this.Controls.Add(myClass.getPanel()); is
called, the old information remains on the form.
Where I'm really lost is the new instance of the panel reflects the
updated information but when it's added to the form, only the first
instance of the panel, with the initial information, is ever
displayed. How can I get the newest panel on the form? I was
thinking about making a call to remove but I'm not sure that would
work when the panel is being created at runtime. Suggestions are
greatly appreciated.
Thanks!