1 / 12

ListBox

ListBox. 1. Предназначение. Списъчната кутия служи да представи информация във вид на списък; Възможности: Избор на едни или повече елемента; Добавяне и премахване на елемент; Сортиране на списък; Преброяване на елементите и др. 2. Местоположение в инструменталната кутия. 3. Свойства.

dbrant
Télécharger la présentation

ListBox

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ListBox

  2. 1. Предназначение • Списъчната кутия служи да представи информация във вид на списък; • Възможности: • Избор на едни или повече елемента; • Добавяне и премахване на елемент; • Сортиране на списък; • Преброяване на елементите и др.

  3. 2.Местоположение в инструменталната кутия

  4. 3. Свойства

  5. 4. Методи

  6. 5. Практическа задача 1 • Създайте следния потребителки интерфейс.

  7. Кодирайте формата, списъчната кутия и бутона по следния начин: Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ListBox1.Items.Add("Canada") ListBox1.Items.Add("USA") ListBox1.Items.Add("UK") ListBox1.Items.Add("Japan") ListBox1.Items.Add("Russia") ListBox1.Items.Add("China") ListBox1.Items.Add("India") End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click MsgBox("You have selected " + ListBox1.SelectedItem.ToString()) End Sub Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged Label2.Text = ListBox1.SelectedItem.ToString() End Sub

  8. 6. Практическа задача 2 • Създайте следния потребителки интерфейс.

  9. Кодирайте формата и бутон 1 по следния начин: Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ListBox1.MultiColumn = True ListBox1.SelectionMode = SelectionMode.MultiExtended End Sub Private Sub Button1_Click_1(sender As Object, e As EventArgs) _ Handles Button1.Click ListBox1.Items.Add("Safety") ListBox1.Items.Add("Security") ListBox1.Items.Add("Governance") ListBox1.Items.Add("Good Music") ListBox1.Items.Add("Good Movies") ListBox1.Items.Add("Good Books") ListBox1.Items.Add("Education") ListBox1.Items.Add("Roads") ListBox1.Items.Add("Health") ListBox1.Items.Add("Food for all") ListBox1.Items.Add("Shelter for all") ListBox1.Items.Add("Industrialisation") End Sub

  10. Кодирайте бутоните по следния начин: Private Sub Button2_Click(sender As Object, e As EventArgs) _ Handles Button2.Click ListBox1.Sorted = True End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) _ Handles Button3.Click ListBox1.Items.Clear() End Sub Private Sub Button4_Click(sender As Object, e As EventArgs) _ Handles Button4.Click ListBox1.Items.Remove(ListBox1.SelectedItem.ToString) End Sub Private Sub Button5_Click(sender As Object, e As EventArgs) _ Handles Button5.Click Label1.Text = ListBox1.Items.Count End Sub Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) _ HandlesListBox1.SelectedIndexChanged Label3.Text = ListBox1.SelectedItem.ToString() End Sub

More Related