本Dictionary的Key和Value都是枚举类型,本例并没实现添加和删除功能,只有编辑功能。
(1)自制弹出窗体
四个控件,ListBox:lBox,ComboBox:cBox,Button:btnOk,还有个Label。
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;
using System.Collections;
namespace WindowsFormsApplication2
{
public partial class FrmDictionaryEditor : Form
{
private IDictionary dic;
private List<string> cBoxList;
private List<string> lBoxList;
private bool initFinished = false;
public FrmDictionaryEditor(IDictionary dic)
{
InitializeComponent();
this.MinimumSize = this.Size;
this.MaximumSize = this.Size;
InitData(dic);
}
private void InitData(IDictionary dic)
{
this.dic = dic;
this.lBoxList = new List<string>();
foreach (var item in dic.Keys)
{