界面編程C# ListBox的基本操作
作者:佚名
下面是C#界面編程的ListBox和ComboBox控件介紹,其中大部分是圍繞是C# ListBox介紹的,很基本,很實際的操作。
下面是C#界面編程的ListBox和ComboBox控件介紹,主要是關于關于C# ListBox的介紹。
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- namespace ListAndCombo
- {
- public partial class ListAndCombo : Form
- {
- public ListAndCombo()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- //初始化設置
- //ListBox 設置
- listBox1.Items.Add("1000 以下");
- listBox1.Items.Add("1001~2000");
- listBox1.Items.Add("2001~3000");
- listBox1.Items.Add("3001~4000");
- listBox1.Items.Add("4001~6000");
- listBox1.Items.Add("6001~8000");
- listBox1.Items.Add("8001~10000");
- listBox1.Items.Add("10000 以上");
- //ComboBox 設置
- comboBox1.Items.Add("身份證");
- comboBox1.Items.Add("學生證");
- comboBox1.Items.Add("教師證");
- comboBox1.Items.Add("軍人證");
- comboBox1.Items.Add("護照");
- }
- private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- label3.Text = listBox1.SelectedItem.ToString();
- }
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- label4.Text = comboBox1.SelectedItem.ToString();
- }
- }
- }
以上就是對編程界面實現的C# ListBox的簡單介紹。
【編輯推薦】
責任編輯:阡陌
來源:
網絡轉載