?
Solved

Autosizing a column in msflexgrid

Posted on 2004-10-20
2
Medium Priority
?
855 Views
Last Modified: 2008-02-01
Is it possible to autosize a column in  the msflexgrid countrol ?
I'm loading text into the grid and would like to resize a particular column in the grid, so the user can see all the data.
(I know I can allow the user to resize the column.)
but I'd like to do it automatically.
Any help appreciated
Paul
0
Comment
Question by:skintpaul
2 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 200 total points
ID: 12356929
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 12356961
Try this:
 - paste this on the form where is your flexgrid
 - add command button to see how to use it
'---------------------------------------------------------------------
Sub AutoSize(FlexGrid As MSFlexGrid, Column As Integer)
    Dim LongestEntry As Integer
    Dim X As Integer
   
   
    If Column >= FlexGrid.Cols Then
        MsgBox "Column " & Column & " does not exist!"
        Exit Sub
    End If
   
    For X = 0 To FlexGrid.Rows - 1
        If TextWidth(FlexGrid.TextMatrix(X, Column)) > LongestEntry Then LongestEntry = TextWidth(FlexGrid.TextMatrix(X, Column))
    Next X
   
    If LongestEntry < 400 Then LongestEntry = 400
    FlexGrid.ColWidth(Column) = LongestEntry * 1.1
End Sub

Private Sub Command1_Click()
    AutoSize MSFlexGrid1, 2
End Sub
'-------------------------------------------------------------------
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question