/// <summary>
/// specify the server id of a Control that replace the default list
/// </summary>
[DefaultValue(null)]
[Category("Appearance")]
[TypeConverter(typeof(CustomListIDConverter))]
public string CustomListID
{
get
{
return (string)ViewState["cl"];
}
set
{
ViewState["cl"]=value;
}
}
/// <summary>
/// Converter of CustomListID
/// </summary>
public class CustomListIDConverter:StringConverter
{
/// <summary>
/// false
/// </summary>
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
{
return false;
}
/// <summary>
/// true
/// </summary>
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
/// <summary>
/// return all designtime Control's ID
/// </summary>
public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
if(context==null)
return null;
ArrayList al=new ArrayList();
foreach(IComponent ic in context.Container.Components)
{
if(ic is ComboBox)
continue;
if(ic is Control)
{
al.Add( ((Control)ic).ID );
}
}
return new TypeConverter.StandardValuesCollection(al);
}
foreach (object item in context.Container.Components)
{
if (item is xxx)
list.Items.Add(((xxx)item).ID);
}
list.BorderStyle = BorderStyle.None;
list.SelectedIndexChanged += new EventHandler(list_SelectedIndexChanged);
if (value != null)
{
int selectedIndex = list.Items.IndexOf(value);
if (selectedIndex >= 0)
list.SelectedIndex = selectedIndex;
}