CaList1.Width = CaList1.Width / 2
How to add controls before resizing and deleting items? Add item? How to delete the controls drpList and Panel in order to redraw the modified LISTBOX? Unsupported unload drpList
Cariolist.ctl
form1.frm,add usercontrol
How to add controls before resizing and deleting items? Add item? How to delete the controls drpList and Panel in order to redraw the modified LISTBOX? Unsupported unload drpList
Cariolist.ctl
Code:
Option Explicit
Private WithEvents Panel As cWidgetForm 'our Host-Widget-Form (here, placed on a normal VB-Form as a Child-Window)
Private WithEvents drpList As cwDropDownList
Dim ListData As New cCollection
Private Sub drpList_Click()
drpList.DropDown.Caption = "Eye: " & drpList.DataSource!Key
Debug.Print drpList.DataSource!Key, drpList.DataSource!Value
End Sub
Private Sub UserControl_Initialize()
UserControl.ScaleMode = vbPixels
Cairo.ImageList.AddIconFromResourceFile "btnIco", "shell32", 167 'load some resource-Icon
Set Panel = Cairo.WidgetForms.CreateChild(UserControl.hWnd) 'create a "Widget-HostPanel"
Panel.WidgetRoot.Zoom = Panel.WidgetRoot.CurrentMonitor.Zoom
End Sub
Sub ShowMe()
Set drpList = Panel.Widgets.Add(New cwDropDownList, "drpList", 0, 0, ScaleWidth, ScaleHeight)
Dim jsonLstStr As String, JsonArr() As String
'= "{""Shapely"":1,""Round"":2,""High Arc"":3}" 'in this demo, each List will get the same drop-down-contents
Dim i As Long
ReDim JsonArr(ListData.Count - 1)
For i = 0 To ListData.Count - 1
JsonArr(i) = Chr(34) & ListData.ItemByIndex(i) & Chr(34) & ":" & ListData.KeyByIndex(i)
Next
jsonLstStr = "{" & Join(JsonArr, ",") & "}"
drpList.Widget.ImageKey = "btnIco"
drpList.SetDataSource New_c.JSONDecodeToCollection(jsonLstStr), "drpList_ds"
drpList.DropDown.Caption = "Eye: <none>"
ScaleMode = vbPixels: Panel.Move 0, 0, ScaleWidth, ScaleHeight
End Sub
Private Sub UserControl_Resize()
ScaleMode = vbPixels: Panel.Move 0, 0, ScaleWidth, ScaleHeight
End Sub
Sub AddItem(ByVal NewItemText As String, ByVal ID As Long)
ListData.Add NewItemText, ID & ""
End Sub
Public Property Get Item(ID As Long) As String
Item = ListData(ID)
End Property
Public Function ListCount() As Long
ListCount = ListData.Count
End Function
Code:
Private Sub Command1_Click()
CaList1.AddItem "item A", 1
CaList1.AddItem "item B", 2
CaList1.AddItem "item C", 3
CaList1.ShowMe
End Sub
Private Sub Command2_Click()
'CaList1.big
CaList1.Width = CaList1.Width / 2
End Sub