使用textwidth()函数
因为我没用过DATAGRID,所以没办法用实例跟你说,只能用MSFLEXGRID为例说明一下
dim MaxLen as single
dim CurLen as single
dim Row as integer
dim Col as integer 'col就是你要调整宽度的列
with msflexgrid1
for row=1 to .rows-1
CurLen=textwidth(.textmatrix(row,col))
if CurLen >MaxLen then
MaxLen=CurLen
endif
next
.column(col).width=maxlen
end with