theSel.Nodes.Add(new SelectorNode("(无)", ""));
if (CommonData.sysmenus != null)
foreach (String aIt in CommonData.sysmenus.Keys)
{
SelectorNode aNd = new SelectorNode(aIt, aIt);
theSel.Nodes.Add(aNd);
if (aIt == (String)theCtx.PropertyDescriptor.GetValue(theCtx.Instance))
theSel.SelectedNode = aNd;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
namespace EX1
{
public class Demo
{
private object[] obj;
public static string prophead = string.Empty;
public object propvaule;
//Demo de = new Demo();
public Demo() { }
public Demo(object[] obj)
{
prophead = obj[0].ToString();
propvaule = obj[1];
}
private int theCountry;
private bool theLanguage;
[CategoryAttribute("基本信息"), DescriptionAttribute("如果你要将用户设置为删除状态,请选择“是”"), DisplayName("删除状态")]
[TypeConverter(typeof(Class2))]
public int Country
{
get
{
return theCountry;
}
set
{
theCountry = value;
}
}
[CategoryAttribute("基本信息"), DescriptionAttribute("如果你要将用户设置为锁定状态,请选择“是”"), DisplayName("锁定状态")]
public bool Language
{
get
{
return theLanguage;
}
set
{
theLanguage = value;
}
}
[CategoryAttribute("基本信息"), DescriptionAttribute("如果你要将用户设置为锁定状态,请选择“是”"), DisplayName("Location")]
public object Obj
{
get
{
return propvaule;
}
set
{
propvaule = value;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace EX1
{
public class Class2 : ComboBoxItemTypeConvert
{
Hashtable hash = new Hashtable();
public override void GetConvertHash()
{
_hash = this.hash;
//_hash.Add("零", 0);
//_hash.Add("一", 1);
//_hash.Add("二", 2);
//_hash.Add("三", 3);
//_hash.Add("四", 4);
}
public void ListToHash(string[] list)
{
for (int i = 0; i < list.Length; i++)
{
hash.Add(list[i].ToString(), i);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections;
namespace EX1
{
public abstract class ComboBoxItemTypeConvert : TypeConverter
{
public Hashtable _hash;
public abstract void GetConvertHash();
public ComboBoxItemTypeConvert()
{
_hash = new Hashtable();
GetConvertHash();
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
string[] ids = new string[_hash.Values.Count];
int i = 0;
foreach (DictionaryEntry myDE in _hash)
{
ids[i++] = (string)(myDE.Key);
}
return new StandardValuesCollection(ids);
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
return true;
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.Xml;
using DevComponents.DotNetBar;
namespace EX1
{
public partial class Form1 : Form
{
XmlDocument mXDoc = new XmlDocument();
public Form1()
{
InitializeComponent();
Load();
//Demo o = new Demo();
//this.advPropertyGrid1.SelectedObject= o; //”propertyGrid1“为PropertyGrid控件
}
public void Load()
{