网站首页 > 文章中心 > 其它

vb.net文字竖排

作者:小编 更新时间:2023-09-10 14:13:17 浏览量:99人看过

如何用VB.net控制word中文字的行间距

你可以参考下这篇教程里面的方法C#设置段落间距,不过需要在你的工程文件中引用Spire.Doc.dll这个类库,

vb.net中使Graphics.DrawString画一字符串都是横着显示,如何让此串字符竖着显示?

gf.DrawString("竖着的值", Font, Brush, new point(X,Y) ,new StringFormat(StringFormatFlags.DirectionVertical));

用这个方法可以

高分求助,如何在VB.NET中做任意角度的旋转字体

请教大家怎么用VB.net控制word中文字的行间

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

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

也不是不可以实现,只不过复杂一点而已,具体看下面代码.不过在需要换行等情况下的文本显示,还是建议用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

VB如何让LABEL里的文字竖排

让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文字竖排相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章