C#APP - 单一Windows窗体中的程序设计 [英] C# APP - Program design in single Windows Form

查看:67
本文介绍了C#APP - 单一Windows窗体中的程序设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是OO和GUI编程的新手,想知道:创建一个在单个表单上标准空间中加载不同功能内容的应用程序的标准方法是什么?换句话说,我有一个单独的表单,顶部有一个工具栏。当有人点击创建新员工时icon我想让工具栏下方的控件更改为创建新员工记录所需的任何内容并将其添加到数据库中。当他们点击查看报告时icon我希望工具栏下方的相同空间可以从创建员工内容更改为当前员工的报告(或其他任何内容)。


我唯一的项目到目前为止,我已经设置了图标来创建并在点击时显示一个新表格。这适用于该应用程序,因为工具栏下方的区域已经加载了经常使用的内容,并且有子窗口很有用。在这个当前的应用程序中,我正在构建,没有任何一个功能我可以预见得到比任何其他功能更多的使用,因此我不希望窗口只有一个工具条,启动多个其他窗口 - 它让我更有意义的是在同一区域而不是在多个窗口中启动功能的内容,因为对于子窗口也没有特别的用途。


我能想到的就是将我的内容放入面板中,这些面板都位于同一个空间中,然后我根据点击的图标以编程方式显示和隐藏它们。那是对的吗?让我知道我应该如何*这样做;)


Maxx

Hi, I''m new to OO and GUI programming and would like to know: what''s a good standard way of creating an application that loads different function-content in a standard space on a single form? In other words, I have a single form with a toolbar across the top. When someone clicks the "create new employee" icon I want the controls below the toolbar to change to whatever''s needed to create a new employee record and add that to the DB. When they click the "View Report" icon I want that same space below the toolbar to change from the ''create employee'' content to a report of current employees (or whatever.)

The only project I''ve done so far I had the icons set up to create and show a new Form whenever clicked. That worked for that app because the area below the toolbar had content loaded that was used very often and it was useful to have child windows. In this current app I''m building however, there''s no one function I can foresee getting any more use than any other function, therefore I don''t want a window with just a toolstrip that launches multiple other windows - it makes more sense to me to launch the function''s content in the same area instead of in multiple windows, as there''s also not really any specific use for child windows.

All I can think of to do this is putting my content into panels that are all positioned in the same space, and which I then programatically show and hide at runtime depending on which icons are clicked. Is that proper? Let me know how I *should* be doing this ;)

Maxx

推荐答案

有人会建议使用MDI孩子为此。

我从来都不喜欢它。

至于你的面板想法,你可以使用TabControl,然后让它不显示它的tabbar at顶部(因此模仿整个系列小组会做什么)。或者您可以让它显示TabBar并将其用作切换方式。


我最近决定使设计更简单的是以单独的形式创建所有内容。请记住,您可以像按钮或任何其他对象一样添加Form对象,您可以创建/显示和关闭任意数量的其他表单。
Some people would suggest that use MDI Children for this.
I have never liked that though.
As for your panels idea, you can use a TabControl and then have it NOT show it''s tabbar at the top (thus mimicing what a whole series of Panels would do). Or you could have it show the TabBar and use that as how they switch.

What I''ve recently decided makes designing a bit easier is to create everything in seperate forms. And keeping in mind that you can add a Form object in the same way you would a Button or any other object, you can create/show and close any number of other forms.


如何做您以与按钮相同的方式添加整个表单?如果我理解正确,那听起来很理想。我能想到的只是在运行时实例化该表单的新实例并显示它 - 但是这会弹出一个* new *窗口,不是吗?有没有办法在VS05中直观地进行操作?


就MDI而言,我对此并不了解。我一直听到谷歌参考这种事情,但是当我开始研究它时,我似乎无法理解它如何适用于我想要做的事情。我已经看到它突然出现了,我肯定我必须遗漏一些重要的东西;)


如果我不理解你的话,这个标签的想法听起来也很棒正确地添加表单构思然后我想我最终会继续这样做。谢谢!


Maxx

How do you add a whole form in the same way as a button? If I''m understanding right that sounds pretty ideal. All I can figure is instantiating a new instance of that form at runtime and showing it - but this pops up a *new* window, no? Is there a way to do it visually in VS05?

As far as MDI, I don''t know much about it. I keep hearing it from google in reference to this sort of thing, but when I start looking into it I can''t seem to make sense of the connection for how it applies to what I''m looking to do. I''ve seen it pop up enough that I''m certain I must be missing something important ;)

The tab idea also sounds great, if I''m not understanding your adding Form idea correctly then I think I''ll end up going with that. Thanks!

Maxx


有些人建议使用MDI儿童。

我从来都不喜欢它。

至于你的面板想法,你可以使用TabControl然后让它不显示它的顶部的tabbar(从而模仿整体系列小组会这样做)。或者您可以让它显示TabBar并将其用作切换方式。


我最近决定使设计更简单的是以单独的形式创建所有内容。请记住,您可以按照与Button或任何其他对象相同的方式添加Form对象,您可以创建/显示和关闭任意数量的其他表单。
Some people would suggest that use MDI Children for this.
I have never liked that though.
As for your panels idea, you can use a TabControl and then have it NOT show it''s tabbar at the top (thus mimicing what a whole series of Panels would do). Or you could have it show the TabBar and use that as how they switch.

What I''ve recently decided makes designing a bit easier is to create everything in seperate forms. And keeping in mind that you can add a Form object in the same way you would a Button or any other object, you can create/show and close any number of other forms.


考虑一下:
Consider this:
展开 | 选择 | Wrap | 行号


这篇关于C#APP - 单一Windows窗体中的程序设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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