|
-
Nov 28th, 1999, 12:31 PM
#1
Thread Starter
New Member
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.
-
Nov 28th, 1999, 06:54 PM
#2
-
Nov 28th, 1999, 06:57 PM
#3
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
[email protected]
[email protected]
ICQ#: 51055819
-
Nov 28th, 1999, 08:13 PM
#4
Thread Starter
New Member
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.?
-
Nov 29th, 1999, 04:27 AM
#5
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.
Code:
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
[email protected]
[email protected]
-
Nov 29th, 1999, 11:55 AM
#6
Thread Starter
New Member
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.
-
Nov 29th, 1999, 12:11 PM
#7
Junior Member
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
-
Nov 29th, 1999, 09:01 PM
#8
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
[email protected]
[email protected]
-
Dec 1st, 1999, 12:29 PM
#9
Thread Starter
New Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|