根据单元格内容自动调整Flexgrid中的单元格高度 [英] autosize cell height in a Flexgrid according to cell contents

查看:785
本文介绍了根据单元格内容自动调整Flexgrid中的单元格高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试根据单元格内容调整flexgrid的单元格高度。



例如:



如果我输入的字符串太长而无法容纳在单元格中,我希望flexgrid根据字符串的数量调整单元格高度拿。



请记住,我不想改变列宽&我正在使用 VBA 而不是VB



我正在使用excel.xlsm工作簿并使用VBE(alt + F11)工作用户表格

用户表单控件:

Flexgrid,

一个文本框,其中(multLine / enterkeybehavior / Wordwrap)属性设置为= True ,

一个命令按钮



我设置它的工作方式:

用户点击在flexgrid中的一个单元格,

这将使文本框可见

用户在文本框中输入文本

用户单击命令按钮,它将文本框的内容传输到flexgrid的单元格。



有人可以帮助解释一下如何添加代码来包装字符串flexgrid单元格或提供示例代码。



任何帮助都非常感谢。

问候

Hi,
I''m trying to adjust the cell height of a flexgrid according the the cell contents.

for example:

if I enter a string that is too long to fit in a cell , I would like to have the flexgrid adjust the cell height according to how many linesthat string would take.

bear in mind that i don''t want to change the column width & I am using VBA not VB

I am using an excel.xlsm work book and working from the VBE (alt+F11) with a user form
the user form controls :
A Flexgrid,
A Text box with (multLine/enterkeybehavior/Wordwrap) properties set to =True,
A command button

the way I have set it up to work:
the user clicks on a cell in the flexgrid,
this will make the text box visible
user enters a text in the text box
user clicks the command button , it transfers the contents of the text box to the cell of the flexgrid)

could someone help shed some light on How do I add code to wrap the string in the flexgrid cell or provide a sample code .

any help is much appreciated.
Regards

推荐答案

要更改列的宽度,请尝试:

To change width of column, try this:
MSFlexGrid1.ColWidth(index) = 1250





向FlexGrid控件添加文本:

1)增加行数



To add text to FlexGrid control:
1) increase the number of rows

Dim i As Integer
i = Flex1.Rows +1
Flex1.Rows = i



2)在第一栏添加文字


2) add text to first column

With Flex1
    .Row = i-1 'the last one
    .Col = 0 'first column
    .Text = TextBox1.Text



结束



http://msdn.microsoft.com/en-us/library/ aa228849%28v = vs.60%29.aspx [ ^ ]


这篇关于根据单元格内容自动调整Flexgrid中的单元格高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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