你可以参考下这篇教程里面的方法C#设置段落间距,不过需要在你的工程文件中引用Spire.Doc.dll这个类库,
gf.DrawString("竖着的值", Font, Brush, new point(X,Y) ,new StringFormat(StringFormatFlags.DirectionVertical));
用这个方法可以
Imports Spire.Doc
Imports Spire.Doc.Documents
Imports System.Drawing
Namespace SetRowSpace
Class Program
? ? Shared? Sub Main(ByVal args() As String)
? ? ? ? '创建文档
? ? ? ? Document doc? =? New Document()
? ? ? ? '添加section
? ? ? ? Dim s As Section =? doc.AddSection()
? ? ? ? '添加段落
? ? ? ? Dim para As Paragraph =? s.AddParagraph()
? ? ? ? para.AppendText("这是测试文字,这是测试文字,这是测试文字,这是测试文字,这是测试文字," +
? ? ? ? ? ? "这是测试文字,这是测试文字,这是测试文字,这是测试文字,这是测试文字,这是测试文字,"+
? ? ? ? ? ? "这是测试文字,这是测试文字,这是测试文字,这是测试文字.")
? ? ? ? '设置段落中行距
? ? ? ? '创建段落样式
? ? ? ? Dim style As ParagraphStyle =? New ParagraphStyle(doc)
? ? ? ? style.Name = "paraStyle"
? ? ? ? style.CharacterFormat.FontName = "宋体"
? ? ? ? doc.Styles.Add(style)
? ? ? ? '应用段落样式
? ? ? ? para.ApplyStyle("paraStyle")
? ? ? ? '保存文档
? ? ? ? System.Diagnostics.Process.Start("SetLineSpacing.docx")
? ? End Sub
End Class
End Namespace
也不是不可以实现,只不过复杂一点而已,具体看下面代码.不过在需要换行等情况下的文本显示,还是建议用RichTextBox开启只读属性比较省心、比较合适.
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)
End?If
str.Append(s(i))
If?i?=?s.Length?-?1?Then?result.Add(str.ToString)
ListBox1.Items.AddRange(result.ToArray)?'填充行内容
End?Using
End?Sub
让LABEL里的文字竖排方法:
调整字号大小到显示单个字,或者收小Label控件的宽度(Width)
代码方法:
Private?Function?Vertical_Horizontal(ByVal?nStr?As?String)?As?String
Dim?MyStr?As?String,?i?As?Integer
Static?Vert?As?Boolean
For?i?=?1?To?Len(nStr)
If?i?Len(nStr)?Then
MyStr?=?MyStr?+?Mid$(nStr,?i,?1)?vbCrLf
Else
MyStr?=?MyStr?+?Mid$(nStr,?i,?1)
Vertical_Horizontal?=?MyStr
Vert?=?True
End?Function
Private?Sub?Form_Load()
Label1.AutoSize?=?True
Label1.Caption?=?"VB如何让标签里的文字竖排"
Label1.Caption?=?Vertical_Horizontal(Label1.Caption)
以上就是土嘎嘎小编为大家整理的vb.net文字竖排相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!