From: David on 23 Mar 2010 19:29 I'm using multiple comboboxes which belong in specific columns. I have the following which does Almost what I want. Private Sub PositionCombo(objCBO As ComboBox, iColumn As Integer) '-------------------------- ' Position the ComboBox over a specific column cell. With objCBO .Visible = False .Left = MSFlexGrid1.Left + MSFlexGrid1.ColPos(iColumn) .Top = MSFlexGrid1.CellTop + MSFlexGrid1.Top .Width = MSFlexGrid1.CellWidth .Visible = True .SetFocus End With End Sub The left border of the combo however, does NOT align with the MsFlexgrid column of interest. What am I missing? Thanks David
From: David on 23 Mar 2010 19:54 The following change seems to work. If there is a "better way", please post. With objCBO .Visible = False objGrid.Col = iColumn '<<set column before move ' .Left = objGrid.Left + objGrid.ColPos(iColumn) .Left = objGrid.CellLeft + objGrid.Left .Top = objGrid.CellTop + objGrid.Top .Width = objGrid.ColWidth(iColumn) .Visible = True .SetFocus End With "David" <NoWhere(a)earthlink.net> wrote in message news:%23PmG6CuyKHA.5940(a)TK2MSFTNGP02.phx.gbl... > I'm using multiple comboboxes which belong in specific columns. > I have the following which does Almost what I want. > > Private Sub PositionCombo(objCBO As ComboBox, iColumn As Integer) > '-------------------------- > > ' Position the ComboBox over a specific column cell. > With objCBO > .Visible = False > .Left = MSFlexGrid1.Left + MSFlexGrid1.ColPos(iColumn) > .Top = MSFlexGrid1.CellTop + MSFlexGrid1.Top > .Width = MSFlexGrid1.CellWidth > .Visible = True > .SetFocus > End With > > End Sub > > The left border of the combo however, does NOT align with > the MsFlexgrid column of interest. What am I missing? > > Thanks > David > > >
From: Bob Butler on 23 Mar 2010 20:14 "David" <NoWhere(a)earthlink.net> wrote in message news:%23cgmhQuyKHA.2436(a)TK2MSFTNGP04.phx.gbl... > The following change seems to work. > If there is a "better way", please post. > > With objCBO > .Visible = False > objGrid.Col = iColumn '<<set column before move > ' .Left = objGrid.Left + objGrid.ColPos(iColumn) > .Left = objGrid.CellLeft + objGrid.Left That's what I've used before; you may no longer need to set the column
From: David on 23 Mar 2010 22:42 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? Sub MSFlexGrid_Click() miSaveColumn = MSFlexGrid.Col '----------------------- 'Position the Comboboxes '----------------------- Call PositionCombo(MSFlexGrid1, cboRepairGroups, GRIDC_Group) Call PositionCombo(MSFlexGrid1, cboRepairNames, GRIDC_Repair) Call PositionCombo(MSFlexGrid1, cboServiceBy, GRIDC_ServiceBy) Call PositionCombo(MSFlexGrid1, cboPartFrom, GRIDC_PartFrom) '----------------- 'Position Text Edit Box over cell 'NOTE: Set Textbox BorderStyle = None '----------------- .Col = miSaveColumn txtDataEntry.Text = .TextMatrix(.Row, .Col) '<< FAILS, AS USES .Col from Call PositionCombo ' txtDataEntry.Text = .TextMatrix(.Row, miSaveColumn) txtDataEntry.Move .CellLeft + .Left, .CellTop + .Top, _ .CellWidth, .CellHeight txtDataEntry.Visible = True DoEvents txtDataEntry.SetFocus End Sub "Bob Butler" <noway(a)nospam.ever> wrote in message news:e6GQzcuyKHA.5036(a)TK2MSFTNGP02.phx.gbl... > > "David" <NoWhere(a)earthlink.net> wrote in message > news:%23cgmhQuyKHA.2436(a)TK2MSFTNGP04.phx.gbl... >> The following change seems to work. >> If there is a "better way", please post. >> >> With objCBO >> .Visible = False >> objGrid.Col = iColumn '<<set column before move >> ' .Left = objGrid.Left + objGrid.ColPos(iColumn) >> .Left = objGrid.CellLeft + objGrid.Left > > That's what I've used before; you may no longer need to set the column >
From: Bob Butler on 24 Mar 2010 10:40 "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
|
Next
|
Last
Pages: 1 2 Prev: DAO 3.6 Next: How to implement a read-only Index property for the members of a Collection? |