开发者

Is their something like iframe in C#?

Is their something like iframe in c#?

I want to build an application with one form that its content changes according to the actions I do, like messenger live. The part when I log in and log out its 开发者_运维问答too different "windows" but it happens in the same form.


There is no iframe equivalent in winforms or wpf, but there are ways to deal with it.

For either winforms or wpf, what you want to do is have a Panel which you change the content of.

A panel is a container which holds/encapsulates other controls.

If you have two different views you want to toggle between, create two panels at the same position with the content you need. Then you will show one and hide the other. When the user executes some action which requires you to change the view, then simply hide the displaying panel, and unhide/show the other one.

Think of it as layers, where you will only show one at a time.

You can also dynamically load user controls into a panel, much like an iframe, but I find it easier to have the content in the form, and hide/show as needed.


Assuming WinForms, how about using UserControls? Place as many as you want in a single/multiple forms, and interact as you do in forms. See, UserControl class.


You can load a form into a Panel or tabPage from a TabControl:

Form f = new Form();
f.TopLevel = false;
panel1.Controls.Add(f);
f.Show();
f.Dock = DockStyle.Fill;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜