Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > TypeConverter

Reply
Thread Tools

TypeConverter

 
 
Martin Venter
Guest
Posts: n/a
 
      11-08-2004
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.StandardValues Collection
GetStandardValues(System.ComponentModel.ITypeDescr iptorContext 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.I TypeDescriptorContext
context)

{

return true;

}

/// <summary>

/// Overrides <see cref="TypeConverter.GetStandardValuesExclusive"/>.

/// </summary>

/// <returns>Returns false.</returns>

public override bool
GetStandardValuesExclusive(System.ComponentModel.I TypeDescriptorContext
context)

{

return false;

}

}

}


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
must be marked as Serializable or have a TypeConverter other than ReferenceConverter to be put in viewstate. jeffpriz@yahoo.com ASP .Net 2 02-23-2005 10:24 PM
Help! Problems with custom TypeConverter and Persistence... Sky Sigal ASP .Net 1 07-14-2004 01:02 AM
must be marked as Serializable or have a TypeConverter other than ReferenceConverter to be put in viewstate Harshdeep Mehta ASP .Net 1 07-08-2004 10:32 AM
TypeConverter for pre-existing system classes? foldface@yahoo.co.uk ASP .Net 0 05-27-2004 04:15 PM
make Serializable or create custom TypeConverter ? Christian ASP .Net 1 07-18-2003 12:42 PM



Advertisments