RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
vbnet换行,vbnet换行符

vb.net中listbox内容自动换行如何实现

也不是不可以实现,只不过复杂一点而已,具体看下面代码。不过在需要换行等情况下的文本显示,还是建议用RichTextBox开启只读属性比较省心、比较合适。

成都创新互联-专业网站定制、快速模板网站建设、高性价比龙华网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式龙华网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖龙华地区。费用合理售后完善,十载实体公司更值得信赖。

Private Sub AutoNextRow()

'获取ListBox行集合文本

Dim length As Integer = (ListBox1.Items.Count - 1)

Dim items(length) As String '行文本数组

For i As Integer = 0 To length

items(i) = ListBox1.Items(i).ToString

Next

'处理ListBox换行

ListBox1.Items.Clear() '清空行内容

Using g As Graphics = Graphics.FromHwnd(ListBox1.Handle)

Dim result As New List(Of Object)

Dim w As Single = ListBox1.ClientSize.Width

Dim sf As SizeF, str As StringBuilder

For Each s As String In items

str = New StringBuilder

For i As Integer = 0 To (s.Length - 1)

sf = g.MeasureString(str.ToString  s(i), ListBox1.Font) 

If sf.Width  w Then

result.Add(str.ToString)

str = New StringBuilder

End If

str.Append(s(i))

If i = s.Length - 1 Then result.Add(str.ToString)

Next

Next

ListBox1.Items.AddRange(result.ToArray) '填充行内容

End Using

End Sub

vb.net 如何识别换行符?

Dim MultiString as String‘有许多行的字符串Dim StrArray() as String'字符串类型的一维数组StrArray=Split(MultiString,VbCrlf)'用换行符分割字符串

VB.NET列表框怎样换行?

1.把ListBox的MultiSelect的属性设为2

2.对滚动条的Scroll事件进行编写

(Added

Attachment)


网站名称:vbnet换行,vbnet换行符
链接分享:http://cqwzjz.cn/article/heiepc.html