G
Guest
I know the following code is C#. I'm a vb programmer trying to learn a new language. I posted this in the c# group but never got a response. You guys seem to know alot about all languages and have all the answers, so here it is..
I'm trying to create a custom listview that uses custom listviewitems. The listviewitems persist just fine in design mode. However, when I build the solution, the listview item doesn't show up. I've run some tests, and the item is still there. However, it's not displayed on the ui
Am I missing something simple? It's still there--why isn't it showing up
Once again, thank you, and sorry about the c#
Tod
Here's my code..
using System
using System.Collections
using System.ComponentModel
using System.ComponentModel.Design
using System.Drawing
using System.Drawing.Design
using System.Data
using System.Windows.Forms
using System.Windows.Forms.Design
namespace ST
[ToolboxItem(true)
public class ListViewEx : System.Windows.Forms.ListVie
{
private ListViewItemCollectionEx m_colItems
public ListViewEx(
SetStyle(ControlStyles.ResizeRedraw, true)
SetStyle(ControlStyles.AllPaintingInWmPaint, true)
SetStyle(ControlStyles.DoubleBuffer, true)
m_colItems = new ListViewItemCollectionEx(this);
[Browsable(true)
[Category("Behavior")
[Description("The items in the ListView.")
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
Editor(typeof(CollectionEditor), typeof(UITypeEditor))
public new ListViewItemCollectionEx Item
get { return m_colItems;
[Serializable()
public class ListViewItemCollectionEx : System.Windows.Forms.ListView.ListViewItemCollectio
{
private ListViewEx m_objParent
public ListViewItemCollectionEx(ListViewEx owner) : base(owner
// Set reference to parent ListViewEx
this.m_objParent = owner
public new ListViewItemEx this[int Index
get { return (ListViewItemEx) base[Index];
public void Add(ListViewItemEx objListViewItemEx
base.Add(objListViewItemEx)
// Give item a reference to parent listview
objListViewItemEx.m_objParent = this.m_objParent
public bool Contains(ListViewItemEx objListViewItemEx
return base.Contains(objListViewItemEx)
public void Remove(ListViewItemEx objListViewItemEx
// Remove item from listview
base.Remove(objListViewItemEx)
// Remove items reference to parent
objListViewItemEx.m_objParent = null;
public void IndexOf(ListViewItemEx objListViewItemEx
base.IndexOf(objListViewItemEx)
[Serializable()
[ToolboxItem(false)
[TypeConverter("STS.ListViewItemExConverter")
public class ListViewItemEx : System.Windows.Forms.ListViewIte
{
internal ListViewEx m_objParent
public ListViewItemEx() : base(
public class ListViewItemExConverter : System.ComponentModel.TypeConverte
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType
if (destinationType == typeof(InstanceDescriptor)
return true
return base.CanConvertTo(context, destinationType)
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType
{
if (destinationType == typeof(InstanceDescriptor) && value is ListViewItemEx
{
ListViewItemEx lvi = (ListViewItemEx)value;
ConstructorInfo ci = typeof(ListViewItemEx).GetConstructor(new Type[] {})
if (ci != null) return new InstanceDescriptor(ci, null, false)
return base.ConvertTo(context, culture, value, destinationType)
I'm trying to create a custom listview that uses custom listviewitems. The listviewitems persist just fine in design mode. However, when I build the solution, the listview item doesn't show up. I've run some tests, and the item is still there. However, it's not displayed on the ui
Am I missing something simple? It's still there--why isn't it showing up
Once again, thank you, and sorry about the c#
Tod
Here's my code..
using System
using System.Collections
using System.ComponentModel
using System.ComponentModel.Design
using System.Drawing
using System.Drawing.Design
using System.Data
using System.Windows.Forms
using System.Windows.Forms.Design
namespace ST
[ToolboxItem(true)
public class ListViewEx : System.Windows.Forms.ListVie
{
private ListViewItemCollectionEx m_colItems
public ListViewEx(
SetStyle(ControlStyles.ResizeRedraw, true)
SetStyle(ControlStyles.AllPaintingInWmPaint, true)
SetStyle(ControlStyles.DoubleBuffer, true)
m_colItems = new ListViewItemCollectionEx(this);
[Browsable(true)
[Category("Behavior")
[Description("The items in the ListView.")
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
Editor(typeof(CollectionEditor), typeof(UITypeEditor))
public new ListViewItemCollectionEx Item
get { return m_colItems;
[Serializable()
public class ListViewItemCollectionEx : System.Windows.Forms.ListView.ListViewItemCollectio
{
private ListViewEx m_objParent
public ListViewItemCollectionEx(ListViewEx owner) : base(owner
// Set reference to parent ListViewEx
this.m_objParent = owner
public new ListViewItemEx this[int Index
get { return (ListViewItemEx) base[Index];
public void Add(ListViewItemEx objListViewItemEx
base.Add(objListViewItemEx)
// Give item a reference to parent listview
objListViewItemEx.m_objParent = this.m_objParent
public bool Contains(ListViewItemEx objListViewItemEx
return base.Contains(objListViewItemEx)
public void Remove(ListViewItemEx objListViewItemEx
// Remove item from listview
base.Remove(objListViewItemEx)
// Remove items reference to parent
objListViewItemEx.m_objParent = null;
public void IndexOf(ListViewItemEx objListViewItemEx
base.IndexOf(objListViewItemEx)
[Serializable()
[ToolboxItem(false)
[TypeConverter("STS.ListViewItemExConverter")
public class ListViewItemEx : System.Windows.Forms.ListViewIte
{
internal ListViewEx m_objParent
public ListViewItemEx() : base(
public class ListViewItemExConverter : System.ComponentModel.TypeConverte
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType
if (destinationType == typeof(InstanceDescriptor)
return true
return base.CanConvertTo(context, destinationType)
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType
{
if (destinationType == typeof(InstanceDescriptor) && value is ListViewItemEx
{
ListViewItemEx lvi = (ListViewItemEx)value;
ConstructorInfo ci = typeof(ListViewItemEx).GetConstructor(new Type[] {})
if (ci != null) return new InstanceDescriptor(ci, null, false)
return base.ConvertTo(context, culture, value, destinationType)