C#如何从“文件”菜单中最好地创建“新建项目”选项 [英] C# How can I best create a 'New Project' option from File menu

查看:102
本文介绍了C#如何从“文件”菜单中最好地创建“新建项目”选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows窗体应用程序,可以有效地管理共享驱动器上一组预定义文件夹中文件的工作流程。即用户可以检出文件并检查它们并将它们移动到QA等,这会在预定义的文件夹结构中移动文件。



但是,此刻此显然只能使用一个项目(以及我编入程序的单个文件夹)。



我希望能够do,有一个File菜单项是''Create new Project''。选中后,会弹出一个对话框,询问项目名称和其他一些信息,然后它会为该新项目创建文件夹结构,然后离开。



用户显然还需要选择要使用的项目,以及选择哪种文件夹结构。



我不知道从哪里开始,所以任何指针都非常有用。在此先感谢。

I have an Windows Forms application that effectively manages workflow on files in a set of predefined folders on a shared drive. i.e users can check files out and check them in and move them to QA etc, which phisically moves the files within the predefined folder structure.

However, at the moment this will obviously only work with a single project (and the single set of folders that i have coded into the program).

What i''d like to be able to do, is have a File menu item that is ''Create new Project''. When selected, a dialog box pops up asking for the project name and maybe a couple of other bits of info, then it creates the folder structure for that new project and away i go.

The user obviously also needs the option to choose which project to work with, and therefore which folder structure.

I have no idea where to start with this, so any pointers would be very useful. Thanks in advance.

推荐答案

设计应用程序的方法有很多种。以下是一个场景。查看您的用户拥有的其他应用程序。看看他们的任何设计范例是否与您的应用程序类型一致。使用您认为是他们最好的想法来设计您的用户互动流程。



一个例子

创建在创建新项目菜单项的单击事件中使用ShowDialog打开的新表单。在新表单中,使用OpenFileDialog控件允许用户选择文件或目录,然后用户填写各种表单控件中的值以定义新项目值。当用户单击确定按钮或创建项目按钮时,将数据插入数据库并关闭表单以返回到主程序。您可能希望主程序显示所有可用项目的列表,或者提供搜索功能以查找和显示所选项目。这是您希望程序与用户交互的方式。如果您是用户,您希望它如何行动?



使用工具箱中的MenuStrip或(较旧的)MainMenu控件创建菜单项。



MenuStrip

为表单提供菜单系统。



MainMenu

表示表单的菜单结构。尽管MenuStrip取代并添加了以前版本的MainMenu控件的功能,但如果您选择,MainMenu将保留以便向后兼容和将来使用。





使用OpenFileDialog控件允许用来选择文件或目录。



OpenFileDialog

表示一个通用对话框,允许用户为要打开的一个或多个文件指定文件名。
There are many ways to design your application. The following is one "scenario". Look at other applications that your users have. See if any of their design paradigms align with your application type. Use what you judge to be the best ideas from them to design your user interaction processes.

One example
Create a new form that you open with ShowDialog in the click event of the Create New Project menu item. In the new form, use the OpenFileDialog control to allow the user to select the file or directory, then the user fills values in various form controls to define the new project values. When the user clicks the OK button or Create Project button, INSERT the data into your database and close the form to return to your main program. You may want your main program to display a list of all available projects or provide a search capability to find and display selected projects. That is a matter of how you want your program to interact with the user. How would you want it to act if you were the user?

Use the MenuStrip or (the older) MainMenu control from the Toolbox to create menu items.

MenuStrip
Provides a menu system for a form.

MainMenu
Represents the menu structure of a form. Although MenuStrip replaces and adds functionality to the MainMenu control of previous versions, MainMenu is retained for both backward compatibility and future use if you choose.


Use the OpenFileDialog control to allow use to select a file or directory.

OpenFileDialog
Represents a common dialog box that allows a user to specify a filename for one or more files to open.


从工具箱中选择MenuStrip

然后在文本中创建新项目



之后添加一个新的窗体表格

并在creat new ptoject的文本下
第一种形式

用对象调用创建表格





喜欢



choose MenuStrip from the toolbox
then write create new project in the text

after that add a new windows form
and under the text of creat new ptoject
in the first form
calling the creation form with object


like

CreateProjectClass cp=new CreateProjectClass();
cp.show();


这篇关于C#如何从“文件”菜单中最好地创建“新建项目”选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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