Solved

Trouble setting width of MSflexigrid

Posted on 2013-11-26
4
185 Views
Last Modified: 2013-11-26
This code only displays part of the last column, it's not wide enough
Sub SetGridWidth()
    Dim i As Integer
    Dim iWidth As Long
    Dim LineWidth As Integer
    LineWidth = 20
    
    For i = 0 To gridStats.Cols - 1
    With gridStats
    iWidth = iWidth + .ColWidth(i) + LineWidth
    End With
    Next i
    gridStats.Width = iWidth

Open in new window


Whats wrong ?
0
Comment
Question by:isnoend2001
[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
  • 2
4 Comments
 
LVL 15

Assisted Solution

by:ChloesDad
ChloesDad earned 500 total points
ID: 39678725
The width of your columns are given in twips, however the width of the control will be in the units as defined by form.scalemode.

Also, it wont work if the font is different in each cell
0
 

Author Comment

by:isnoend2001
ID: 39678745
Thanks
All the fonts are the same, how do i write it
0
 
LVL 15

Accepted Solution

by:
ChloesDad earned 500 total points
ID: 39678785
You can set it at runtime by using

Form1.ScaleMode = vbtwips
0
 

Author Closing Comment

by:isnoend2001
ID: 39678925
Thanks I have changed the line width to 38 and will leave it at that, it's close enough
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

690 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