2

Hy,

In my c# application i want to make a box were i can put text in line by line to display information about what the application is currently doing. I tried to look on the Internet because this is a very common way of interfacing with users, and im sure there are lots of samples out there. The problem is, i don't know how i should call this kind of textbox.

I hope it's clear to you guys what im looking for!

EDIT 1

I want a box like the one in this installer.

image
(source: softpedia-static.com)

4

3 回答 3

7

您可以使用多行文本框,然后将其设为只读且不可编辑。您只需附加该行并添加回车符 (\r\n)

      TextBox1.text += "More text" + " \r\n";
于 2013-06-26T13:34:33.260 回答
2

AmitApollo 的回答是完美的。

如果您担心盒子的外观,请尝试设置这些属性:

  • Font:如果您希望控制台看起来像 DOS 控制台,请尝试使用固定宽度的字体,例如 Consolas 或 Courier New。
  • BackColor:将其设置为灰色以使框看起来像图像中的框

此外,如果您想将新日志添加到框的开头,请使用

txtConsole.text = "Log's text" + " \r\n" + txtConsole.text;

如果您希望该框在添加新行时滚动到最后一行,请查看此帖子

于 2013-06-26T13:47:22.647 回答
1

我会给你一些提示,你可以继续研究,我不会给你一个提供项目完整工作代码的答案:

  1. 创建用户界面
  2. 这将是一个多行文本框
  3. 设置进度条以执行代码正在执行的操作
  4. 设置一个循环来显示进度条的进度

我会警告你这是相对困难的,所以你需要进一步研究。

许多人认为进度条会自动显示进度,这是不正确的。您可以采用两种方式,将计时器放在进度条上,或者将其设置为更新您工作所经历的每一行代码。我希望您现在开始了解在您的代码中创建这可能是多么困难。但请记住,困难并非不可能享受学习!

于 2013-06-26T13:43:28.607 回答