告诉我看表格输出的过程 [英] tell me a procedure to see the output on form

查看:60
本文介绍了告诉我看表格输出的过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio2008进行C#编程.我正在写命令-console.writeline(这是我的第一个程序");
但是当我们按下执行按钮时看不到输出.
您能告诉我一个在窗体上查看此结果的过程吗.

I am using the visual studio2008 for c # programming. I am writing a command - console.writeline("this is my first program ");
But not able to see the output when we press the execution button.
Can you please tell me a procedure to see this result on form.

推荐答案

存在两个可能的问题:

1)如果您将其创建为控制台应用程序,则可能是该应用程序运行太快而无法看到.在您的Main方法的末尾添加以下行:
There are two possible problems:

1) If you have created this as a console application, then it may be that the application runs too quickly for you to see. Add this line at the end of your Main method:
Console.ReadLine();

这将使软件停止,直到您按ENTER键.您应该现在就可以看到您的文本.

2)如果已将其创建为WinForms应用程序,则需要在Visual Studio中单击输出"窗格以查看控制台输出.如果找不到,请在查看...输出"下的菜单上查看



我认为您没有完全理解我的主要问题.我再次解释.我是新用户,我正在编写一个打印行的程序(这是我的第一个程序);代码中没有错误.该程序在我按下启动调试按钮程序时运行,并仅显示一个简单的小屏幕."


问题:小窗口"是黑色还是灰色?

如果为黑色:这是一个控制台应用程序.确保您的Console.WriteLine指令在"process.cs"文件的Main方法中.

如果是灰色:这是一个WinForms应用程序:丢弃您的Console.WriteLine指令并打开工具箱(从菜单:所有Windows窗体"下的查看...工具箱"将一个按钮拖到您的窗体上.
双击按钮,然后在代码中添加以下行:

This will make the software stop until you have pressed the ENTER key. You should be able to see your text now.

2) If you have created this as a WinForms application, then you need to click on the "output" pane in Visual Studio to see the console output. If you can''t find it, look on the menu under "View...Output"



"i think you not fully under stand my main problem. i explain it again. i am a new user i am write a program that print a line (this is my first program); no error in the code.after right the program when i am a press a start debugging button program run and show only a simple small screen."


A question: is the "small window" black, or grey?

If it is black: this is a console application. Make sure your Console.WriteLine instruiction is in the Main method in the file "process.cs"

If it is grey: this is a WinForms application: Discard your Console.WriteLine instruction and open the toolbox (From the menu: "View...Toolbox" under "All Windows Forms" drag a button onto your form.
Double click the button and add the following line to your code when it appears:

MessageBox.Open("Hello Pucit009!");





我真的非常感谢您.我接近您的问题,我的问题是第二个选择.该解决方案代表消息框.但是我只说了一条语句.就像(您好,我的第一个程序)
就像在Java代码中打印一样(Hello World)
我想用C#打印.然后在表格上,您要添加按钮."


OK:您想要的是一个控制台应用程序.

1)关闭解决方案(菜单:文件...关闭解决方案")
2)创建一个新项目(菜单:文件...新项目")
3)在新项目对话框中,选择控制台应用程序"
4)在名称:"文本框中给它取一个明智的名称.
5)按确定"

现在,如果您查看"Program.cs"(在屏幕的RHS上的解决方案资源管理器"中双击),您将找到一个名为Main的方法,该方法非常空白.将您的Console.WriteLine放在此处(不要忘记最后的Console.ReadLine()!),并且在运行时它将是简单的文本.





"i am really very thank full to ans me. you near to my problem my problem is second option. that solution is represent the message box. but i am right only a single statement. just like a (hello its my first program)
simply like print in the java code (hello world)
i want to print in c#. and on the form where is the you ask a add button."


OK: what you want is a Console App.

1) Close your solution (Menu: "File...Close solution")
2) Create a new project (Menu: "File...New Project")
3) In the new project dialog, select "Console Application"
4) Give it a sensible name in the "Name:" text box.
5) Press "OK"

Now if you look in "Program.cs" (double click in the Solution explorer on the RHS of your screen) you will find a method called Main which is pretty empty. Put your Console.WriteLine in there (don''t forget the Console.ReadLine() at the end!) and when you run that it will be simple text.


如果该应用程序不是控制台类型.只有两种程序集类型:Windows应用程序,控制台应用程序和类库,这是一个编译器选项.另请参阅项目的属性",应用程序"选项卡,输出类型".

如果将UI应用程序的类型更改为"Console Applicaion",则可以使用控制台.那么您将同时拥有控制台和UI.但是,没有必要这样做.

要输出任何文本,请使用控件,例如TextBox.要逐行添加文本,ListBox很方便.为了进行记录,请使用System.Diagnostics.EventLog.

由于使用调试可能会出现问题,因此您可能需要在末尾添加以下内容:

It is ignored if the application is not of console type. There are only two Assembly types: Windows Application, Console Application and Class Library, this is a compiler option; see also project''s Properties, Application tab, "Output type".

You can have console if you change the type of your UI application to "Console Applicaion"; then you will have both console and UI. However, there is no need to do that.

To output any text, use controls, such as TextBox. To append text line-by-line, ListBox is convenient. For logging purposes, use System.Diagnostics.EventLog.

As it can be a problem using debugging, you may want to add the following at the end:



只需添加一行Console.ReadKey();即可.在末尾.在程序退出之前,您需要按任意键.

希望这会有所帮助.
一切顺利.
Just add a line Console.ReadKey(); at the end. It will need you press any key before the programme exits.

Hope this helps.
All the best.


这篇关于告诉我看表格输出的过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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