Vb. NET Learning Notes (III.)

Source: Internet
Author: User

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))

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.