Click to See Complete Forum and Search --> : Detecting row/column resizing in MSFlexGrid.OCX??


Christian
January 17th, 1999, 10:11 PM
Hi,


I'm currently faced with a problem in VB5 of trying to detect when any row or column in a MSFlexGrid ActiveX control is resized by the user.


Is this achievable and if so, how can it be done?

Chris Eastwood
January 18th, 1999, 04:47 AM
Hi


This is very annoying huh ? I spent forever trying to capture the resize of

a column or row using subclassing and I just couldn't find anything. Even the MouseUp messages aren't fired at the correct time when you resize.


Eventually I got around it by having a timer which stores the total width

of all columns / all rows statically in its event and then check the values

to see if there's be a change,


ie. Something like (from the top of my head)


Sub Timer ...


Static lColumnWidth As Long

Static lRowHeight As Long

Dim lCounter As Long

Dim lTemp As Long


For lCounter = 0 To MSFlexGrid1.Cols -1

lTemp = lTemp + MSFlexGrid1.ColWidth(lCounter)

Next

If lTemp lColumnWidth Then

' Columns been resized

lColumnWidth = lTemp

End If


lTemp = 0

For lCounter = 0 To MSFlexGrid1.Rows - 1

lTemp = lTemp + MSFlexGrid1.RowHeight(lCounter)

Next

If lTemp lRowHeight Then

' Row's been resized

lRowHeight = lTemp

End If


End Sub


You can put your own resize code in at the commented lines.


If however, you need to capture a resize event because you're implementing grid editing, I'd suggest capturing the row/colchanged event (can't remember what it's called off the top of my head). You can then hide the control when required.


Hope it helps


Chris Eastwood

Software Engineer

ACNielsen Ltd

Robert Maier
April 23rd, 1999, 10:46 AM
Hi,
my problem with a flexgrid is, the user shall be able to change the column sizes as he likes - except of a couple of certain columns, that should be hidden, hence have the colwidth zero and should be unchangable.
The proposed method with the timer to me seems to pull the performance down, because to do it efficiently this timer should be evoked within time intervalls small enough for the user not to notice someone's narrowing the columns, that he was just going to expand.
Did you encounter such problems with this solution?
Regards,
Robert

Chris Eastwood
April 23rd, 1999, 12:29 PM
Hi

There was an article posted recently on the CodeGuru site to detect resizing of Columns in a FlexGrid - it should also apply to row resizing.

Take a look at :

http://www.codeguru.com/vb/articles/1721.shtml

Regards

Chris Eastwood


CodeGuru - the website for developers
http://www.codeguru.com/vb