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(DesignerSerializat ionVisibility.Content)
Editor(typeof(CollectionEditor), typeof(UITypeEditor))
public new ListViewItemCollectionEx Item
get { return m_colItems;
[Serializable()
public class ListViewItemCollectionEx : System.Windows.Forms.ListView.ListViewItemCollecti o
{
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) 5 5782
Is your list view in "large icon" mode? That is the default property -
change it to "details" and your item might show up.
"ToddH" <an*******@discussions.microsoft.com> wrote in message
news:F9**********************************@microsof t.com... 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#, Todd
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 STS { [ToolboxItem(true)] public class ListViewEx : System.Windows.Forms.ListView { 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(DesignerSerializat ionVisibility.Content), Editor(typeof(CollectionEditor), typeof(UITypeEditor))] public new ListViewItemCollectionEx Items { get { return m_colItems; } } }
[Serializable()] public class ListViewItemCollectionEx :
System.Windows.Forms.ListView.ListViewItemCollecti on { 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.ListViewItem { internal ListViewEx m_objParent;
public ListViewItemEx() : base() { }
}
public class ListViewItemExConverter : System.ComponentModel.TypeConverter { 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); } }
}
It doesn't work in any mode. Also, that wouldn't make it disappear when I compile or run it. I can see the items in design mode before I build it--no matter what mode. But running it makes the items not repaint. Bizarre
Todd
Are you executing a "clear" in code at all? Often, its possible to "clear"
the columns by mistake, when you just want to clear the items. Well, these
are the 2 reasons I have discovered for the annoying "missing items" problem
in VB.NET. I can't think of any more ;)
"ToddH" <an*******@discussions.microsoft.com> wrote in message
news:DD**********************************@microsof t.com... It doesn't work in any mode. Also, that wouldn't make it disappear when I
compile or run it. I can see the items in design mode before I build it--no
matter what mode. But running it makes the items not repaint. Bizarre. Todd
Nope. I'm not doing anthing to the items. In fact, I add them through the collection editor at design-time. After that, I'm not touching them
Todd
Check they are in the collection at runtime with a breakpoint - check the
items.count property.
"ToddH" <an*******@discussions.microsoft.com> wrote in message
news:58**********************************@microsof t.com... Nope. I'm not doing anthing to the items. In fact, I add them through the
collection editor at design-time. After that, I'm not touching them. Todd This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Simon Middlemiss |
last post by:
I am writting a program to manage DTS packages which is based on the code
example at the following link
http:\\www.support.microsoft.com/?kbid=319985.
I need to do things in a Windows Forms...
|
by: Martin Schulze |
last post by:
Hello,
i tried to compose myself a custom usercontrol which is derieved from
System.Windows.Forms.UserControl.
It contains 2 comboboxes and one textbox (which are also custom
controls,
but...
|
by: Tinus |
last post by:
Hello all,
I've create a custom control (UserControl) and have a custom Item
Collection. The control is a custom calendar which is draw using the
Graphics Rectangle etc. functions. It is drawn...
|
by: Jeff |
last post by:
I've made a custom Listview control, and i want this
control to use a custom ColumnHeader control that I've
created. how can i do this
thanks
|
by: Piotr Strycharz |
last post by:
Hi,
I need to develop a custom control. The control is going to be something
like Properties window in VS - listview (grid?) with resizable columns and
collapsable sections.
The control needs...
|
by: Rob |
last post by:
When a custom control is used within a form, that control does not get
events directly. I've run into this a couple times with both mouse
and keyboard events.
Ex: A custom control inherits from...
|
by: =?Utf-8?B?YnJhaW5mdWVsbWVkaWE=?= |
last post by:
Can anyone point me in the direction of creating a custom listview item? I
guess the other question then - is this possible? I want to create a list of
listview items comprised each comprised of...
|
by: a |
last post by:
Hi
I would like to add some additional custom features to the listview, like
cell editing. The created object will be added to the form as part of the
GUI, and it should be able to handle...
|
by: Mark Olbert |
last post by:
How do I get the DataPager and ListView to play nice together when I use a custom datasource?
In my webpage, I use linq to pull data from a SqlServer database and assign the resulting...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |