Link to home
Start Free TrialLog in
Avatar of yronnen
yronnen

asked on

Strange behaviour in MSHFlexgrid celltop property

I'm writing a VB6 application that involves an in-cell editing of a MSHFlexgrid control using comboboxes and text boxes.

In order to set the position of the combo boxes, I use the following code:

cmbGlasses(I).Move fgGlassSub.Left + fgGlassSub.CellLeft, _
                              fgGlassSub.Top + fgGlassSub.CellTop, _
                              fgGlassSub.CellWidth - 8


It should be working, but instead I get a strange behaviour:
The grid is hidden and a I click on a button to see it. When it opens for the first time, the moment I click on a row, it opens the combo box exactly at the next row! If there is only one row, it will show the combo box on the an "empty" background of the MSHFlexgrid.
But the most strange this is that the moment I have enough rows in the grid to show a scroll it begins to work fine, even if I delete rows or reloads the grid with not enough rows to show a scroll.

The grid is inside a frame on the form.

Any ideas for this strange behaviour?

TIA
Avatar of Sethi
Sethi
Flag of India image

Please post the full code. The code you have written above is absolutely correct. The problem seems to be somewhere else. You can however, optimize the above code like this:
Avatar of Nazermohideeen
Nazermohideeen

Hi yronnen,
 
     Try in this way by adding the control to MSHFlexgrid by mshflexgrid.controls.Add()

          Then it would be more flexible and probably you would get into a solution. Also you need not worry about the left and top of the grid, as because once the control is added to the grid, the acts as a small form and the control can only move within the grid, so the left and top of the grid is 0, 0 for the control.

If this dosen't work, Please post the full code.
Cheers
Nazer
 
Avatar of yronnen

ASKER

The full code is a monster....I can't send it.

Sethi: your answer does not include the code.
Someone else was having the problem that reading the CellTop property in the Scroll event procedure of a MSFlemGrid when either the first or last row was selected stopped the scrolling from working properly!

These controls are just screwy, they lack basic functionality and are just designed to make you cry.  If you're doing a major project (or you just want to hold onto your sanity a bit longer) I might recommend using a half decent third-party grid control.  We used the Janus grid a few years back and while it had some daft bugs, it was nothing like as painful as the MSFlemGrids.  There might be better ones out now (there's bound to be other rubbish as well).

Anyway, the work-around I suggested to that other poor sole was to add up the RowHeights from the TopRow to Row - 1 (or something like that) to get the CellTop.  Fixed their problem (what a mess though!) - dunno if it will help you.

Hmmm... "The full code is a monster"... when using the MSHFlemGrid, what a suprise.
My posting the code, I only mean that portion of the code where you are moving this combo. Even if it is a huge code post the relevant parts to see where the problem lies.
Option Explicit

Private Sub Form_Load()
    With Me.MSFlexGrid1
        .Rows = 10
        .Cols = 5
        Text1.Visible = False
    End With
End Sub

Private Sub MSFlexGrid1_Click()
    With MSFlexGrid1
        .Row = .MouseRow
        .Col = .MouseCol
        Text1.Move .Left + .CellLeft, .Top + .CellTop, .CellWidth, .CellHeight
        Text1.Visible = True
    End With
End Sub
ASKER CERTIFIED SOLUTION
Avatar of supunr
supunr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Moderator, my recommended disposition is:

    Accept supunr's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer