...and UserControlOne appears.
i want to close(remove) UserControlOne on Cancel()(Cancel is function in UserControlOne) and load another User Control (UserControl2) to panel2:
Last edited by peter_budo; Nov 2nd, 2009 at 7:26 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
since you always clear the controls on the panel first, seems like it will always be the only control on the panel, so panel2.controls. clear(); should work.
but you could also use panel2.Controls[0].Remove();
seems like there could be several ways to go about it.
you could even expose the panel2 as a public property of the form and modify its contents directly through the property.
since you always clear the controls on the panel first, seems like it will always be the only control on the panel, so panel2.controls. clear(); should work.
but you could also use panel2.Controls[0].Remove();
seems like there could be several ways to go about it.
you could even expose the panel2 as a public property of the form and modify its contents directly through the property.
yes, that's ok. my code works too. but i want to in usercontrolone on Cancel close that control(that is done) and load another usercontrol(UserControl2). funny thing is that the panel2 is already a public property and i can't access it from UserControl2 (or i don't know how
should i access panel2 with following code:
string test = this.Parent.Name; //doesn't work, parent is NULL ?!
milosz: What happens when your code runs? I haven't tested it but it looks like it should run OK...
my code is ok. UserControlOne disappears from panel2. But I want somehow to enable for UserControlTwo to appear when I close UserControlOne. I can do that by using events, but is there any other way?
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.