Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSFLEXGRID Column Width

Status
Not open for further replies.

jadams0173

Technical User
Feb 18, 2005
1,210
I've done this before but for some reason it's not working now. I have a MSFLEXGRID and I want to hid the last column so I did this:

Code:
TheGrid.ColWidth(18) = 0 'id

However the column is still the width of it's heading in the fixed column. If I change the width from 0 to 2000 the column gets wider, but it will not hide completely. I'm pulling my hair out. Does anyone have any suggestions.

Here is part of the function that is located in a class module. The part I left out is just the loading of the data. If it is relevent I'll post it as well.
Code:
Function PopulateEngWildcardFlexGrid(frm As Form, rsEngWildcard As ADODB.Recordset, _
TheGrid As MSFlexGrid)
Dim x       As Integer
Dim i       As Integer
Dim c       As Integer

'Populate the flexgrid
frm.Show

TheGrid.Enabled = True
TheGrid.Clear

TheGrid.cols = 19
TheGrid.rows = rsEngWildcard.RecordCount + 1
TheGrid.FixedRows = 1
TheGrid.FixedCols = 0

TheGrid.Row = 0
TheGrid.FormatString = "Customer|^Location|<Assy Number|<Tool Number|<Rev|<Job Number|" _
& "^Date Entered|Disposition|Transfer To|Used|<Comments|<Raw Card PN|^Tool Size|" _
& "Updated On|Updated By|Dispositioned As|Disp By|Disp Date|id"

TheGrid.ColWidth(0) = 1300
TheGrid.ColWidth(1) = 1500
TheGrid.ColWidth(2) = 2000
TheGrid.ColWidth(3) = 2000
TheGrid.ColWidth(4) = 550
TheGrid.ColWidth(5) = 1000
TheGrid.ColWidth(6) = 2300
TheGrid.ColWidth(7) = 1100
TheGrid.ColWidth(8) = 1000
TheGrid.ColWidth(9) = 550
TheGrid.ColWidth(10) = 2500
TheGrid.ColWidth(11) = 2000
TheGrid.ColWidth(12) = 750
TheGrid.ColWidth(13) = 1000
TheGrid.ColWidth(14) = 750
TheGrid.ColWidth(15) = 900
TheGrid.ColWidth(16) = 1000
TheGrid.ColWidth(17) = 1000
[red]TheGrid.ColWidth(18) = 0 'id[/red]
[blue]'TheGrid.ColWidth(TheGrid.cols - 1) = 0[/blue]
 
I think that your FormatString won't let it be changed to less than the length of the defined heading width. Try dropping the "id" at the end of FormatString.
 
or scrub Formatstring and substitute

' modify column's headers
.TextMatrix(0, 0) = "NO"
.TextMatrix(0, 1) = "Locattion"
.TextMatrix(0, 2) = "Assay"


.ColWidth(0) = 1300
.ColWidth(1) = 1500
.ColWidth(2) = 2000

.ColAlignment(0) = flexAlignCenterCenter
.ColAlignment(1) = flexAlignLeftCenter
.ColAlignment(2) = flexAlignLeftCenter

' make header bold
.Row = 0
.Col = 0
.RowSel = .FixedRows - 1
.ColSel = .Cols - 1
.CellFontBold = True

 
I don't have a problem with it, but I usually add a hidden column at the end with no header. Try adding an extra column and hide it also (set width to 0).

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
I'll give these ideas a try. I had the exact same code that I moved from a form to the class to make it so I could pass in certain parameters to populate flexgirds. I have this code in another application(same app but I'm upgrading some stuff) and it works as expected.

Code:
Sub PopulateFlexGrid() '(RsToUse As String)
Dim L           As Integer
Dim xx          As Integer

'On Error GoTo PopulateFlexGrid_Error
lblRecordcount.FontBold = True
lblRecordcount.AutoSize = True
lblRecordcount.Visible = True

'make sure the cmdscrap button is enabled and the flexgrid is enabled
cmdScrap.Enabled = True

With MSFlexGrid1
    .Enabled = True
    
    .Clear
    
    .cols = 11 '0-9 is 10 columns
    
    .rows = rs.RecordCount + 1
        
    .FixedRows = 1
    .FixedCols = 0
    
    .Row = 0
    .FormatString = "<Location|<Part Number|<Raw Card|<Tool Number|<Rev|<Job#|<Comments|<Disposition|<Transfer To|<Disp By|<Disp Date|id|Size"
    
    .ColWidth(0) = 1100
    .ColWidth(1) = 1000
    .ColWidth(2) = 1000
    .ColWidth(3) = 1200
    .ColWidth(4) = 500
    .ColWidth(5) = 1000
    .ColWidth(6) = 2715
    .ColWidth(7) = 1100
    .ColWidth(8) = 1000
    .ColWidth(9) = 1000
    .ColWidth(10) = 1000
    .ColWidth(11) = 0 'KEEP THE ID HID. IT WILL BE SHOW ON THE EXCEL REPORT.
    .ColWidth(12) = 600
    .Redraw = False

I have no clue why when I moved it to the class and added some more fields why it won't hide now.
 
If I drop the id from the format string, the column will hide. I don't understand why I could hide it earlier with the column header in it and now I can't. I tried adding a blank extra column and it wouldn't hide.
 
as an experiment

have you tried HIDING any OTHER Columns

If They wont hide ... I would suspect it hse to do with FormatString
 
Yes I have tried to hide other columns and they won't hide either. The code in the post I made on 23 Apr 08 6:53 works and the column will hide.

I took that code and put it in a class and now the column won't hide. No column will hide. If I take the code back to the form, it works. I've deleted the grid and added it back just for kicks. That had no effect. If I leave the last column of the format string off it will hide. But, I have no clue as to why putting it in a class makes the grid behave differently.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top