1. ListBox binding Data
Dim DT Asnew DataSet
DT = Djgl. Returndt ("Select name from T_item where type= ' control List '")
Listbox1.datasource = dt. Tables (0)
Listbox1.displaymember = "Name"
Listbox1.valuemember = "Name"
2, Tag property
The type of tag is object, so you can save any control of controls, which is easier to invoke.
3, ListView binding Data and multiple column display
LISTVIEW1.COLUMNS.ADD (CH1)
LISTVIEW1.COLUMNS.ADD (CH2)
Dim rcount asinteger = dt. Tables (0). Rows.Count
Dim I Asinteger
For i = 0 to RCount-1
LISTVIEW1.ITEMS.ADD (dt. Tables (0). Rows (i) (0). ToString ()) plus the first column
Listview1.items (i). SubItems.Add ("NULL") plus second column
Next
4, the ListBox right menu and select
in the MouseDown event:
If E.button = Windows.Forms.MouseButtons.Right Then
Dim Sindex Asinteger = Listbox1.indexfrompoint (e.x, e.y)
If Sindex <>-1 Then
Listbox1.selectedindex = Sindex
Listbox1.contextmenustrip = ContextMenuStrip1
Else
Listbox1.contextmenustrip = Nothing
EndIf
EndIf
5. ListBox multi-selection value
Apply Listbox1.selecteditems to the selected project collection, each DataRowView type
Dim II, IRC asinteger
Dim ll as DataRowView
IRC = ListBox1.SelectedItems.Count
For II = 0 to Irc-1
LL = Listbox1.selecteditems (ii)
MsgBox (LL. Row (0). ToString ())
Next
6, String color value
Color.FromArgb (Convert.ToInt32 ("Ffffffff--argb", 16))