Click to See Complete Forum and Search --> : How to hide column in Flexgrid
GeeKay
Nov 28th, 1999, 11:31 AM
Hi,
I am facing difficulty in hiding a column in Flex Grid. We are hiding the column by setting the colWidth(N) = 0 , since the AllowUserResizing is set to True , the user is able to see the hidden column.
There is a property called ColIsVisible(N) which gives the status of the column , hidden or not.
But this seems to be a read only property whereas in MSDN (help) it states that one can set/read the property.
The version of flexgrid we are using is 6.00.8418.
Could you please suggest as to how you hide a column in MSFLEXGRID.
Note: The requirement is to allow the user to resize.
Thank You.
Ishamel
Nov 28th, 1999, 05:54 PM
Here's what I would do, but it would mean the AllowUserResize property will need to be set to False so the column remains hidden.
msFlexGrid1.Colwidth(X) = 1
msFlexGrid1.AllowUserResize = FALSE
msFlexGrid1.WordWrap = TRUE
I would then resize each row's height so that the Word Wrap facility displays all data in each cell. (This will remove any requirement to allow the user to resize the cells)
This site gives more info on how to go about doing this.
http://support.microsoft.com/support/kb/articles/Q178/1/27.ASP
Hope this helps. :)
Serge
Nov 28th, 1999, 05:57 PM
Unfortunately, MsFlexGrid doesn't have visible property for every column, BUT....
You can set it's Width to 0 (zero), to have that effect.
MSFlexGrid1.ColWidth(1) = 0
It will nake the second column hidden.
------------------
Serge
Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
GeeKay
Nov 28th, 1999, 07:13 PM
Thanks for you replies.
But the above solution do not solve the problem.
The requirement is to allow the user to resize the columns. The column is to be conditionally hidden. Setting the column width to zero still allows the user to resize the hidden column (which we don't want)
Is there any other way to hide the columns in the flex grid.?
Aaron Young
Nov 29th, 1999, 03:27 AM
Try using the MouseMove Event to Calculate which Column the Pointer is over, then Disable the Resizing Dynamically Depending on the Width of the Cell, where Zero Width Depicts a Disabled/Hidden Column eg.
Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim iCell As Integer
With MSFlexGrid1
For iCell = 0 To .Cols - 1
If x >= .ColPos(iCell) And x <= .ColPos(iCell) + .ColWidth(iCell) Then Exit For
Next
If iCell < .Cols Then
If (x - .ColPos(iCell)) < (.ColWidth(iCell) / 2) Then
iCell = iCell - 1
If iCell < 0 Then iCell = 0
End If
.AllowUserResizing = IIf(.ColWidth(iCell) > 0, flexResizeColumns, flexResizeNone)
End If
End With
End Sub
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net
GeeKay
Nov 29th, 1999, 10:55 AM
Hi Aaron,
I did try with the code you sent but does'nt solve the problem.
Say i have 5 columns and I hide the 3&4th column ,in the form load event by setting the col width of 3&4 to Zero.)
Now in the mouse move event what i can do is if .mousecol = 3 then
.colwidth(3) = 0
endif
This does solve the problem when the user clicks on the header row (col3) and pulls it holding the mouse button (down). once he moves out of the column then the mouse move event fires. but if he does'nt move the mouse outside the header row then the column gets resized and ends up showing the hidden column.
Hope somehow i could muddle thru this.
sushant
Nov 29th, 1999, 11:11 AM
It seems that the MouseMove event of the grid is not triggering correctly when the user drags the hidden (.colwidth =0) column. Therefore we have to use an external event to set the colwidth to 0. So I've used a timer control. In the following example, the 3rd column is hidden. The flex grid name is msgDetails.
Private Sub Timer1_Timer()
With msgDetails
If .Redraw = False Then
.Redraw = True
End If
If .ColWidth(3) <> 0 Then
.Redraw = False
.ColWidth(3) = 0
End If
End With
End Sub
Aaron Young
Nov 29th, 1999, 08:01 PM
I Created 5 Columns, Hid the 3rd and 4th Columns and couldn't resize them using the Code I posted.
Are you sure you copied the Code I posted Exactly into the Correct Event?
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net
GeeKay
Dec 1st, 1999, 11:29 AM
Hi Aaron,
Thanks for UR help.
After some R & D we have come to a conclusion that in Flexgrid one can hide the columns provided the columns that u hide lies between the first and last column.
i.e: by setting colwidth(n)=0 .
If you hide columns in the beginning or at the end then the user can resize it by pulling it out.
Thanks once again
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.