using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ToUpdateGasStationMis.練習
{
public partial class FrmDemo : Form
{
public FrmDemo()
{
InitializeComponent();
}
/// <summary>
/// 顯示listBox
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
this.listBox1.Items.Clear();
this.listBox1.Items.Add("軟件部");
this.listBox1.Items.Add("測試部");
this.listBox1.Items.Add("採購部");
this.listBox1.Items.Add("銷售部");
this.listBox1.Items.Add("人事部");
}
/// <summary>
/// 添加ListBox
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
try
{
listBox1.Items.Insert(2, "插入值");
label1.Text = "已添加" + listBox1.Items.Count.ToString() + "記錄條數";
}
catch (Exception ex )
{
}
}
/// <summary>
/// ListBox 點擊彈窗
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
MessageBox.Show("您選擇的部門是:"+listBox1.SelectedItem.ToString()+"位列第"+listBox1.SelectedIndex.ToString(),"信息提示!");
}
/// <summary>
/// 打開加載
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void FrmDemo_Load(object sender, EventArgs e)
{
this.comboBox1.Items.Add("a1");
this.comboBox1.Items.Add("a2");
this.comboBox1.Items.Add("a3");
this.comboBox1.Items.Add("a4");
this.comboBox1.Items.Add("a5");
this.comboBox1.Items.Add("a6");
this.comboBox1.Items.Add("a7");
}
}
}
winfrom ListBox 使用 點擊彈窗
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.