Here is the solution. A ListBox descendant that maintains its own data
source connection and only allows the base control to see it a run time.
This then fixes what I beleive to be a bug, the list box cannot grab the
data at design time. This also works exactly the same for ComboBox
[ToolboxBitmap(typeof(ListBox))]
public class AdvancedListBox : ListBox
{
private Object _DataSource;
[TypeConverter("System.Windows.Forms.Design.DataSourceConverter,System.Design")]
public new Object DataSource
{
get
{
return _DataSource;
}
set
{
_DataSource = value;
if (!DesignMode)
base.DataSource = value;
}
}
[DefaultValue("")]
private string _DisplayMember = string.Empty;
[TypeConverter("System.Windows.Forms.Design.DataMemberConverter,System.Design")]
public new string DisplayMember
{
get
{
return _DisplayMember;
}
set
{
_DisplayMember = value;
if (!DesignMode)
base.DisplayMember = value;
}
}
[DefaultValue("")]
private string _ValueMember = string.Empty;
[TypeConverter("System.Windows.Forms.Design.DataMemberConverter,System.Design")]
public new string ValueMember
{
get
{
return _ValueMember;
}
set
{
_ValueMember = value;
if (!DesignMode)
base.ValueMember = value;
}
}
}
--
Andrew Cutforth - AJC Software -
www.ajcsoft.com The best folder synchronize and directory compare tool available.
AJC Active Backup instantly archives every file you edit giving you
unlimited undo and automatic revision control. Never lose your data again.