1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| Public WithEvents framm As MSForms.Frame
Public WithEvents formm As UserForm
Public WithEvents dropp As MSForms.Image
Public WithEvents selecté As MSForms.TextBox
Public WithEvents labLt As MSForms.Label
Public WithEvents combo As MSForms.ComboBox
Private usf(100) As New combofake
Function combocolor(comb, bicolorbyrow, Optional GriDline As Boolean = False, Optional GrildLineColor As Variant = vbBlack)
Dim cW, ecW#, ecL#, Fram, Ssel, Drop, i#, col#, cc#
cW = Split("0;" & Replace(comb.ColumnWidths, " pt", ""), ";")
Set Fram = comb.Parent.Controls.Add("Forms.Frame.1", "fond", True): Fram.Width = 100: Fram.Visible = False
Set Ssel = comb.Parent.Controls.Add("Forms.textbox.1", "selectio", True)
Set Drop = comb.Parent.Controls.Add("Forms.image.1", "drop", True)
Ssel.Move comb.Left + comb.Width + 50, comb.Top, comb.Width, comb.Height
Drop.Move Ssel.Left + Ssel.Width - Ssel.Height, Ssel.Top + 1, Ssel.Height - 2, Ssel.Height - 2
Drop.SpecialEffect = 1
Fram.Move Ssel.Left, Ssel.Top + Ssel.Height, Ssel.Width, Ssel.Width
For i = 0 To comb.ListCount - 1
ecL = IIf(GriDline, IIf(i > 0, 1 * i, 0), 0) 'on enleve 1*i pour que les borduretop et bottom se croisent (effet bordercollapse)
For col = 0 To comb.ColumnCount - 1
cc = cc + 1
Set ligne = Fram.Controls.Add("Forms.label.1", "Lig" & i & "Ligcol" & col, True)
ligne.Tag = "Lig" & i & "Ligcol" & col
With ligne
ecW = IIf(GriDline, IIf(col > 0, 1 * col, 0), 0) 'on enleve 1*i pour que les bordureright et left se croisent (effet bordercollapse)
.Caption = comb.List(i, col): .AutoSize = True: .Font.Size = comb.Font.Size:
.BorderStyle = IIf(GriDline, 1, 0)
.BorderColor = IIf(GriDline, GrildLineColor, 0)
.WordWrap = False: .Top = (.Height * i) - ecL: .Width = cW(col + 1): .Left = cW(col) - ecW: .AutoSize = False
.BackColor = IIf(i Mod 2 = 0, bicolorbyrow(1), bicolorbyrow(0))
Set usf(cc).formm = comb.Parent: Set usf(cc).framm = Fram: Set usf(cc).combo = comb
Set usf(cc).dropp = Drop: Set usf(cc).labLt = ligne: Set usf(cc).selecté = Ssel
End With
Next
Next
With Fram
.Height = .Controls(1).Height * comb.ListRows + IIf(GriDline, 5, 15): .ScrollBars = 3: ScrollHeight = 100
End With
'l'icone du bouton
'82,36,73
On Error Resume Next
CommandBars("temp").Delete
With ActiveSheet.Shapes.AddShape(36, 10, 10, 10, 15): .Line.Visible = False: .Fill.ForeColor.RGB = (vbBlue): .Fill.Visible = True: .Copy: .Delete: End With
Set mabarre = CommandBars.Add("temp", msoBarPopup, False, True): Set bouton = mabarre.Controls.Add(Type:=msoControlButton):
bouton.PasteFace
Drop.Picture = bouton.Picture
On Error Resume Next
CommandBars("temp").Delete
'comb.visible=false
End Function
Private Sub dropp_Click()
framm.Visible = True
framm.ScrollHeight = framm.Controls(1).Height * (framm.Controls.Count / combo.ColumnCount) - 1 * framm.Controls.Count / combo.ColumnCount
combo.DropDown
'
End Sub
Private Sub labLt_Click()
formm.Controls(combo.Name).Tag = Split(labLt.Tag, "col")(1)
formm.Controls(combo.Name).ListIndex = Split(labLt.Tag, "Lig")(1)
selecté.Value = labLt.Caption
framm.Visible = False
End Sub
Private Sub formm_Click()
framm.Visible = False
End Sub |
Partager