如何在VB6中编辑数据网格的宽度和对齐字段? [英] How to edit the width and align fields of datagrid in VB6?

查看:451
本文介绍了如何在VB6中编辑数据网格的宽度和对齐字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有用VB6编写的数据网格的应用程序.我想编辑datagrid的width和align(center或right)字段.我无法.

你能帮我吗?

I have a application with a datagrid that is written in VB6. I want to edit the width and align(center or right) fields of datagrid. I am unable to.

Can you help me?
Thanks.

推荐答案

宽度->谢谢. DataGrid.Columns(n).Width = 1200

对于对齐->由于我的系统上没有Visual Basic 6.0,因此我不记得了.
For Width -> DataGrid.Columns(n).Width = 1200

For Aligning -> Since I don''t have visual basic 6.0 on my system, I am unable to remember that.


这行不通吗?!
Doesn''t this work?!
DataGrid1.Columns(0).Alignment = dbgCenter
DataGrid1.Columns(0).Alignment = dbgRight


您可以尝试使用此替代方法来对齐列标题.

You can try this workaround for alignment of column header.

Dim W As Long
Dim SpaceWidth As Long
Dim NumOfSpaces As Long
Dim ColumnHeaderText As String
ColumnHeaderText = "Hello"
With DataGrid1
  SpaceWidth = Me.TextWidth(" ")
  W = .Columns(1).Width
  NumOfSpaces = (W - Me.TextWidth(ColumnHeaderText)) \ SpaceWidth \ 2
  .Columns(1).Caption = Space


这篇关于如何在VB6中编辑数据网格的宽度和对齐字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆