Visual Studio如何使用页面C# [英] Visual studio how to work with pages C#

查看:156
本文介绍了Visual Studio如何使用页面C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以即使我有一个表单,我想按下按钮时屏幕上当前的所有内容都会消失并显示新页面(不是新表单)。我尝试使用用户控件来实现这一点,但在用户控件的代码中我只是非常隐藏用户控件而不是让新的用户控件出现。



我想要实现的是,让我们说一个带有不同文本框和1个按钮的屏幕,当你按下那个按钮时,它们都会消失,包括按钮,然后出现新的按钮和文本框。有人可以帮助我实现这个目标吗?



我尝试过的事情:



搜索互联网,但我找不到任何可以帮助我的东西。



我也尝试使用面板,但很难设计带有多个面板的表格。

so im i have a a form and i want when you press a button everything that is currently on the screen disappears and a new page shows up (not a new form). i tried to achieve this with user controls but within the code of a user control i was only ably to hide that user control but not to let a new one show up.

what i want to achieve is that there is lets say a screen with different text boxes and 1 button and when you press that button they all disappear including the button and then new buttons and text boxes show up. can someone help me achieving this ?

What I have tried:

searching the internet but i could not find anything that could help me.

also i tried to work with panels but it was hard to design the form with multiple panels.

推荐答案

不要尝试在用户控件中执行此操作:相反,让控件生成下一页请求事件,父表单通过关闭处理控制并开启一个新的。这样,控制器不必知道是否有更多的页面,但是父母 - 毕竟是负责的 - 确实。



听起来可能很复杂,但事实并非如此。请参阅此处:在两个表单之间传输信息,第2部分:从孩子到父母 [ ^ ] - 它是关于表单的讨论,但它对用户控件的工作方式完全相同!
Don;t try to do it from within the user control: instead, have the control generate a "next page request" event which the parent form handles by closing the control and opening a new one. That way, teh control doesn't have to know if there are more pages, but teh parent - which is in charge after all - does.

It may sound complicated, but it isn't, not at all. See here: Transferring information between two forms, Part 2: Child to Parent[^] - it's talks about forms, but it works exactly the same way for user controls!


你需要的是一个 TabControl。 [ ^ ]

如果需要,可以这样隐藏标签:如何隐藏TabControl标题 [ ^ ]
What you need is a TabControl.[^]
If you want, you can hide the tabs this way: How to Hide TabControl Headers[^]


这篇关于Visual Studio如何使用页面C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆