M
Martin Venter
Hi Everyone,
I have a custom dropdownlist control with a LoadItemsFrom property.
I created a TypeConverter for this property that displays a list of controls
of the same type in the property designer.
This all works great but I would like to exclude the control from the list
that is being inspected.
Hope someone can shed some light on this.
Below is the code of my TypeConverter.
Regards,
Martin
#region ... using ...
using System;
using System.Collections;
using System.ComponentModel;
using System.Web.UI;
#endregion
namespace Unison.Galactrix.Web.UI.WebControls
{
/// <summary>
/// Summary description for AuxiliaryCodesDropDownListConverter.
/// </summary>
public class AuxiliaryCodesDropDownListConverter : StringConverter
{
public AuxiliaryCodesDropDownListConverter()
{
}
/// <summary>
/// Gets the list of controls in the container.
/// </summary>
/// <param name="container">The <see cref="IContainer"/> to search in for
controls.</param>
/// <returns>An array of <see cref="Control"/> ID <see
cref="String"/>.</returns>
protected virtual Object[] GetControls( IContainer container )
{
ArrayList standardValues = new ArrayList();
foreach( IComponent component in container.Components )
{
Control control = component as Control;
if ((control != null) && (control is AuxiliaryCodesDropDownList))
{
standardValues.Add(String.Copy(control.ID));
}
}
standardValues.Sort();
return standardValues.ToArray();
}
/// <summary>
/// Overrides <see cref="TypeConverter.GetStandardValues"/>.
/// </summary>
/// <returns>Returns an array of <see cref="Control"/> ID <see
cref="String"/>.</returns>
public override System.ComponentModel.TypeConverter.StandardValuesCollection
GetStandardValues(System.ComponentModel.ITypeDescriptorContext context)
{
if (context == null || context.Container == null)
{
return null;
}
object[] standardValues = this.GetControls(context.Container);
if (standardValues != null)
{
return new StandardValuesCollection(standardValues);
}
return null;
}
/// <summary>
/// Overrides <see cref="TypeConverter.GetStandardValuesSupported"/>.
/// </summary>
/// <returns>Returns true.</returns>
public override bool
GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext
context)
{
return true;
}
/// <summary>
/// Overrides <see cref="TypeConverter.GetStandardValuesExclusive"/>.
/// </summary>
/// <returns>Returns false.</returns>
public override bool
GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext
context)
{
return false;
}
}
}
I have a custom dropdownlist control with a LoadItemsFrom property.
I created a TypeConverter for this property that displays a list of controls
of the same type in the property designer.
This all works great but I would like to exclude the control from the list
that is being inspected.
Hope someone can shed some light on this.
Below is the code of my TypeConverter.
Regards,
Martin
#region ... using ...
using System;
using System.Collections;
using System.ComponentModel;
using System.Web.UI;
#endregion
namespace Unison.Galactrix.Web.UI.WebControls
{
/// <summary>
/// Summary description for AuxiliaryCodesDropDownListConverter.
/// </summary>
public class AuxiliaryCodesDropDownListConverter : StringConverter
{
public AuxiliaryCodesDropDownListConverter()
{
}
/// <summary>
/// Gets the list of controls in the container.
/// </summary>
/// <param name="container">The <see cref="IContainer"/> to search in for
controls.</param>
/// <returns>An array of <see cref="Control"/> ID <see
cref="String"/>.</returns>
protected virtual Object[] GetControls( IContainer container )
{
ArrayList standardValues = new ArrayList();
foreach( IComponent component in container.Components )
{
Control control = component as Control;
if ((control != null) && (control is AuxiliaryCodesDropDownList))
{
standardValues.Add(String.Copy(control.ID));
}
}
standardValues.Sort();
return standardValues.ToArray();
}
/// <summary>
/// Overrides <see cref="TypeConverter.GetStandardValues"/>.
/// </summary>
/// <returns>Returns an array of <see cref="Control"/> ID <see
cref="String"/>.</returns>
public override System.ComponentModel.TypeConverter.StandardValuesCollection
GetStandardValues(System.ComponentModel.ITypeDescriptorContext context)
{
if (context == null || context.Container == null)
{
return null;
}
object[] standardValues = this.GetControls(context.Container);
if (standardValues != null)
{
return new StandardValuesCollection(standardValues);
}
return null;
}
/// <summary>
/// Overrides <see cref="TypeConverter.GetStandardValuesSupported"/>.
/// </summary>
/// <returns>Returns true.</returns>
public override bool
GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext
context)
{
return true;
}
/// <summary>
/// Overrides <see cref="TypeConverter.GetStandardValuesExclusive"/>.
/// </summary>
/// <returns>Returns false.</returns>
public override bool
GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext
context)
{
return false;
}
}
}