From: David on
Thanks for your time.
I
> typically don't do much in the Click event of any control and prefer to
> separate the functional code from the event handling

I agree. Sometimes use the event during test in case logic off as saves
making another procedure.

Starting to "delve" into MsFlexgrid as didn't do much with in the past.
So climbing the learning curve.

Have a nice day.

"Bob Butler" <noway(a)nospam.ever> wrote in message
news:OOPwjA2yKHA.5132(a)TK2MSFTNGP05.phx.gbl...
>
> "David" <NoWhere(a)earthlink.net> wrote in message
> news:%23qDphuvyKHA.928(a)TK2MSFTNGP05.phx.gbl...
>> Mr. Butler:
>>
>> Thanks for input. Your suggestion works if you have one combo
>> and want it to be placed into the cell that is clicked.
>>
>> In my case, I have 4 combo's, which should be pegged to their
>> specific column, such that if a new row is added, they move within their
>> column to the new row.
>>
>> The following routine (as posted works) but has created other issues.
>> (see problem below code)
>>
>> With objCBO
>> .Visible = False
>> objGrid.Col = iColumn '<<Set Column so Cell values work
>> .Left = objGrid.CellLeft + objGrid.Left
>> .Top = objGrid.CellTop + objGrid.Top
>> .Width = objGrid.ColWidth(iColumn)
>> .Visible = True
>> ' .SetFocus '<<Generates Error Here???
>>
>> 'Set Flex row Height = Combo Height since
>> ' combo height is Not adjustable
>> objGrid.RowHeight(objGrid.Row) = .Height
>>
>> End With
>>
>> I call the above from the below MSFlexgrid_Click event. As previously
>> stated combo's move correctly. HOWEVER, it appears setting the
>> objGrid.Col = iColumn kepts the last column position upon return to
>> MSFlexgrid_Click and causes the txtDataEntry box NOT to position itself
>> in the correct cell. I've saved the column value upon entry into
>> MSFlexGrid_Click in a module variable, and restore it before the
>> txtEntryData is processed (see below). This seems to work somewhat, but
>> is there a better / different solution?
>
> There are other ways to do it but I'm not sure any are "better". I
> typically don't do much in the Click event of any control and prefer to
> separate the functional code from the event handling (warning - air code
> below)
>
> Private Sub MSFlexGrid_Click()
> If MSFlexGrid.MouseRow>0 Then
> PositionControls MSFlexGrid1, MSFexGrid.Row, MSFlexGrid.Col
> End If
> End Sub
>
> Private Sub PositionControls(ByVal TheGrid As MSFlexGrid, _
> ByVal TheRow As Long, ByVal TheCol As Long)
> '-----------------------
> 'Position the Comboboxes
> '-----------------------
> Call PositionCombo(TheGrid, cboRepairGroups, GRIDC_Group)
> Call PositionCombo(TheGrid, cboRepairNames, GRIDC_Repair)
> Call PositionCombo(TheGrid, cboServiceBy, GRIDC_ServiceBy)
> Call PositionCombo(TheGrid, cboPartFrom, GRIDC_PartFrom)
> '-----------------
> 'Position Text Edit Box over cell
> 'NOTE: Set Textbox BorderStyle = None
> '-----------------
> txtDataEntry.Text = .TextMatrix(TheRow, TheCol)
> TheGrid.Row=TheRow
> TheGrid.Col=TheCol
> txtDataEntry.Move .CellLeft + .Left, .CellTop + .Top, .CellWidth,
> .CellHeight
> txtDataEntry.Visible = True
> txtDataEntry.SetFocus
> End Sub
>
>