Click here to Skip to main content
15,886,075 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 20-Feb-13 0:55am
v2
Comments
CHill60 20-Feb-13 6:55am    
I've amended the tags on your question from "VB6" so that the appropriate people will actually look at the question

1 solution

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


To add text to FlexGrid control:
1) increase the number of rows
VB
Dim i As Integer
i = Flex1.Rows +1
Flex1.Rows = i

2) add text to first column
VB
With Flex1
    .Row = i-1 'the last one
    .Col = 0 'first column
    .Text = TextBox1.Text

End With

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900