没有合适的资源?快使用搜索试试~ 我知道了~
VB6.0中编辑MSHFlexGrid强制换行并调整列宽及行高.txt
需积分: 48 14 下载量 139 浏览量
2021-01-25
13:09:13
上传
评论
收藏 5KB TXT 举报
温馨提示
试读
4页
VB6.0中根据每一个单元格的内容根据指定的列宽强制换行,并根据单元格的内容调整行高和列宽
资源推荐
资源详情
资源评论
Private Sub Form_Load()
With MSHFlexGrid1
.Cols = 4
.Rows = 4
.TextMatrix(1, 1) = "1"
.TextMatrix(2, 1) = "2"
.TextMatrix(3, 1) = "3"
.TextMatrix(1, 2) = "这是一个行高自动调整的过程"
.TextMatrix(1, 3) = "短"
.TextMatrix(2, 2) = "短文本"
.TextMatrix(2, 3) = "这是一个行高自动调整的过程测试"
.TextMatrix(3, 2) = "可以了"
.TextMatrix(3, 3) = "好"
txt1.Text = Me.TextWidth(.TextMatrix(1, 2)) '(1,2)单元格文本宽度
txt2.Text = Me.TextWidth(.TextMatrix(1, 3)) '(1,2)单元格文本宽度
txt3.Text = Me.TextWidth(.TextMatrix(2, 2)) '(2,2)单元格文本宽度
txt4.Text = Me.TextWidth(.TextMatrix(2, 3)) '(2,3)单元格文本宽度
txt9.Text = Me.TextHeight(.TextMatrix(1, 2)) '(1,2)单元格文本高度
txt10.Text = Me.TextHeight(.TextMatrix(2, 3)) '(2,3)单元格文本高度
.WordWrap = True
End With
' AutoColWidth 100, Me, MSHFlexGrid1
' AutoRowHeight 100, Me, MSHFlexGrid1
End Sub
Private Sub Command1_Click()
'思想是:设置ColNum列为固定列宽Length,则1行显示文本;超过Length但未超过2*Length ,则分2行显示文本;
'超过2*Length但未超过3*Length ,则分3行显示文本。然后根据ColNum的TextHeight来设置行高
Dim Length As Integer, ColNum As Integer, RowNum As Integer, TextLength As Integer
Length = 0 '固定列宽,7个文字的宽度
With MSHFlexGrid1
With MSHFlexGrid1
.Cols = 4
.Rows = 4
.TextMatrix(1, 1) = "1"
.TextMatrix(2, 1) = "2"
.TextMatrix(3, 1) = "3"
.TextMatrix(1, 2) = "这是一个行高自动调整的过程"
.TextMatrix(1, 3) = "短"
.TextMatrix(2, 2) = "短文本"
.TextMatrix(2, 3) = "这是一个行高自动调整的过程测试"
.TextMatrix(3, 2) = "可以了"
.TextMatrix(3, 3) = "好"
txt1.Text = Me.TextWidth(.TextMatrix(1, 2)) '(1,2)单元格文本宽度
txt2.Text = Me.TextWidth(.TextMatrix(1, 3)) '(1,2)单元格文本宽度
txt3.Text = Me.TextWidth(.TextMatrix(2, 2)) '(2,2)单元格文本宽度
txt4.Text = Me.TextWidth(.TextMatrix(2, 3)) '(2,3)单元格文本宽度
txt9.Text = Me.TextHeight(.TextMatrix(1, 2)) '(1,2)单元格文本高度
txt10.Text = Me.TextHeight(.TextMatrix(2, 3)) '(2,3)单元格文本高度
.WordWrap = True
End With
' AutoColWidth 100, Me, MSHFlexGrid1
' AutoRowHeight 100, Me, MSHFlexGrid1
End Sub
Private Sub Command1_Click()
'思想是:设置ColNum列为固定列宽Length,则1行显示文本;超过Length但未超过2*Length ,则分2行显示文本;
'超过2*Length但未超过3*Length ,则分3行显示文本。然后根据ColNum的TextHeight来设置行高
Dim Length As Integer, ColNum As Integer, RowNum As Integer, TextLength As Integer
Length = 0 '固定列宽,7个文字的宽度
With MSHFlexGrid1
资源评论
vv520笑看风云
- 粉丝: 0
- 资源: 26
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功