Click here to Skip to main content
11,501,968 members (69,080 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Excel VBA
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 20-Feb-13 0:50am
Edited 20-Feb-13 0:55am
CHill6095.3K
v2
Comments
CHill60 at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

To add text to FlexGrid control:
1) increase the number of rows
Dim i As Integer
i = Flex1.Rows +1
Flex1.Rows = i
2) add text to first column
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[^]
  Permalink  

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



Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 19 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100