[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Autosizing a column in msflexgrid

Posted on 2004-10-20
2
Medium Priority
?
854 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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 …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 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