vb6中的form.textwidth(str)函数,移植到vb2012中用什么函数转换?

kirawoo 2014-09-29 09:16:06
vb6中的form.textwidth(str)函数,移植到vb2012中用什么函数转换?

VB6
函数名: textwidth
功 能: 返回以像素为单位的字符串宽度
...全文
472 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yagede 2015-05-12
  • 打赏
  • 举报
回复
楼主解决这个问题没有啊,我也碰到相同的问题了,搞了好久都没有弄明白
kirawoo 2014-09-29
  • 打赏
  • 举报
回复
我使用个Grid是MSHFlexGrid,用这个代码是自动调整列宽的功能
kirawoo 2014-09-29
  • 打赏
  • 举报
回复
你好,我是想把下面vb6中的代码,转换到VB2012中可是TextWidth函数在vb2012中无法转换,请问有什么办法? Public Sub AdjustColWidth(frmCur As Form, gridCur As Object, Optional bNullRow As Boolean = True, Optional dblIncWidth As Double = 0) '-------------------------------------------------------------------- '功能: ' 自动调整Grid各列列宽为最合适的宽度 '参数: ' [frmCur].........................................当前工作窗体 ' [gridCur]........................................当前要调整的Grid '-------------------------------------------------------------------- Dim i, j As Integer Dim dblWidth As Double With gridCur For i = 0 To .Cols - 1 dblWidth = 0 If .ColWidth(i) <> 0 Then For j = 0 To .Rows - 1 If frmCur.TextWidth(.TextMatrix(j, i)) > dblWidth Then dblWidth = frmCur.TextWidth(.TextMatrix(j, i)) End If Next .ColWidth(i) = dblWidth + dblIncWidth + 100 End If Next End With End Sub
threenewbee 2014-09-29
  • 打赏
  • 举报
回复
http://msdn.microsoft.com/zh-cn/library/system.drawing.graphics.measurestring(v=vs.110).aspx

1,453

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧