简体   繁体   English

到达表单C#(WinForm)末尾时在下一行继续的文本

[英]Text that continues in next line when it reaches the end of the form C# (WinForm)

So i want to make a WinForm app that will start typing text from the upper left corner all the way to the lower right corner like a console application, when it reaches the end of a line it continues in a new line. 因此,我想制作一个WinForm应用程序,它将像控制台应用程序一样从左上角一直到右下角开始输入文本,当它到达一行的末尾时,它将继续换行。

eg: 例如:

>line 1:     I need y
>
>line 2:     our help

The text should be chopped, if you get what i mean. 如果您理解我的意思,那么文本应该被砍掉。

You should use RichTextBox for this purpose. 为此,您应该使用RichTextBox It represents a rich text control that supports formatted text, hyperlinks, inline images, and other rich content. 它表示一个富文本控件,支持格式文本,超链接,嵌入式图像和其他富内容。

RichTextBox.TextWrapping Property of RichTextBox can help you. RichTextBox.TextWrapping的属性RichTextBox可以帮助你。

  • It gets or sets how text wrapping occurs if a line of text extends beyond the available width of the RichTextBox . 它获取或设置如果一行文本超出RichTextBox的可用宽度时如何进行换行。
  • You should consider the width of the RichTextBox when you set the TextWrapping property. 设置TextWrapping属性时,应考虑RichTextBox的宽度。
  • Any text that extends beyond the bounds of the RichTextBox will not be displayed. 超出RichTextBox边界的任何文本都不会显示。 If the TextWrapping property is set to NoWrap , text that exceeds the horizontal bounds can be scrolled into view using the cursor. 如果TextWrapping属性设置为NoWrap ,则可以使用光标将超出水平界限的文本滚动到视图中。 Text that exceeds vertically can be scrolled into view using the keyboard or scrollbar. 可以使用键盘或滚动条将垂直超出的文本滚动到视图中。
  • If the TextWrapping property is set to Wrap, the HorizontalScrollBarVisibility property is automatically set to Disabled and any property changes to the HorizontalScrollBarVisibility are ignored. 如果TextWrapping属性设置为Wrap,则HorizontalScrollBarVisibility属性将自动设置为Disabled,并且对HorizontalScrollBarVisibility所做的任何更改都将被忽略。

You can use MultiLine Textbox .. you have to notice that 您可以使用MultiLine Textbox ..您必须注意

[1] Will be easier if you use fix width fonts .. this the idea (not real code) [1]如果您使用固定宽度的字体会更容易..这个想法(不是真实的代码)

charlimit = me.width / textwidth("A") ----> use graph textrender function here

[2] You can control textbox_textchanged event to ensure that the word not get ' autowrap ' to next line .. so when the text position is in most right position you can chop it by add the text with vbCrLf .. [2]您可以控制textbox_textchanged事件,确保了字拿不到“autowrap”到下一行..所以当文本的位置是在最合适的位置,你可以砍它通过文字与vbCrLf加..

if LastLine.Length = charlimit then

     alltext += vbCrLf

     lastLine = ""

endif

But this would be hard when you do in middle row because you have to reccount the words after it (below it) .. 但这在中行时很难,因为您必须记下其后的单词(在其下方)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM