﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Anyway to expose ListView.Columns property?</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 01:25:49 GMT</lastBuildDate><ttl>20</ttl><item><title>Anyway to expose ListView.Columns property?</title><link>http://forum.strataframe.net/FindPost4788.aspx</link><description>I have a SF Usercontrol that has a SF ListView on it. I would like to expose the Columns property as a public property of the Usercontrol, as this is needed to configure it (and I'd like to keep it declarative).&lt;br&gt;
&lt;br&gt;
The problem is that the Columns property is Readonly (.Net limitation).  I've tried defining the property as a ColumnHeaderCollection. This works fine for the Get section, but in the Set section I have to use code like:&lt;br&gt;
&lt;br&gt;
For each col As ColumnHeader in value&lt;br&gt;
  Me.lvwAny.Columns.Add(col)&lt;br&gt;
Next col&lt;br&gt;
&lt;br&gt;
The property then shows up in the property windows and allows me to set columns, which show up at runtime. However as soon as I build it, the columns aren't associated with the ListView either at runtime or when I go back into design mode, though they are defined within the designer (i.e. individual ColumnHeader objects are defined, but not associated with the ListView at all).&lt;br&gt;
&lt;br&gt;
Any ideas on how I might do this?</description><pubDate>Tue, 28 Nov 2006 14:31:49 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Anyway to expose ListView.Columns property?</title><link>http://forum.strataframe.net/FindPost4833.aspx</link><description>ah....:satisfied:</description><pubDate>Tue, 28 Nov 2006 14:31:49 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Anyway to expose ListView.Columns property?</title><link>http://forum.strataframe.net/FindPost4831.aspx</link><description>Yeah, exposing the toolstrip is a good way to do it... most likely, the type editor is trying to access the "parent" of the property being edited and directcasting it to ToolStrip, which you user control is not.&amp;nbsp; So, exposing the whole thing would probably be your best bet.&lt;/P&gt;&lt;P&gt;As for attaching handlers to the click events of buttons added in the first designer, you'll have to do that programmatically like this:&lt;/P&gt;&lt;P&gt;AddHandler Me.ToolStripProperty.Items(0).Click, AddressOf MyButton_Click</description><pubDate>Tue, 28 Nov 2006 14:14:42 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Anyway to expose ListView.Columns property?</title><link>http://forum.strataframe.net/FindPost4828.aspx</link><description>Thanks.  Yeah, I know it is the .NET type editor.  Also, unless there is some way to associate code to the click event of any buttons added via the designer, I'm not sure it's worth it (otherwise, I've got a button that does nothing). I've exposed the ToolStrip itself and can add buttons and handle events of the button this way.</description><pubDate>Tue, 28 Nov 2006 14:07:26 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Anyway to expose ListView.Columns property?</title><link>http://forum.strataframe.net/FindPost4826.aspx</link><description>I'm not sure... I'll have to test this.&amp;nbsp; That's not our type editor, though... it's .NET's type editor.</description><pubDate>Tue, 28 Nov 2006 13:58:40 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Anyway to expose ListView.Columns property?</title><link>http://forum.strataframe.net/FindPost4808.aspx</link><description>When I attempt to open the type editor I get an error. I've attached a screen shot of the message box.</description><pubDate>Tue, 28 Nov 2006 11:43:53 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Anyway to expose ListView.Columns property?</title><link>http://forum.strataframe.net/FindPost4805.aspx</link><description>That's strange, the Items property is ReadOnly... what does the error message you're receiving say exactly? and when do you get the error message? when you open the type editor, or when you try to exit the type editor and save your changes?</description><pubDate>Tue, 28 Nov 2006 11:32:05 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Anyway to expose ListView.Columns property?</title><link>http://forum.strataframe.net/FindPost4802.aspx</link><description>OK, I must have moved onto the second gotcha :crazy:...&lt;br&gt;
&lt;br&gt;
I tried the same sort of thing to expose the Items collection of a SF ThemedToolStrip and I get a parameter is null error for the value parameters.  I set up the property as readonly, so I don't know were this value parameter is coming from (the type editor I'm guessing).&lt;br&gt;
&lt;br&gt;
You have any idea of what going on here?</description><pubDate>Tue, 28 Nov 2006 11:14:16 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Anyway to expose ListView.Columns property?</title><link>http://forum.strataframe.net/FindPost4793.aspx</link><description>Not a problem... that's one of the first "gotchas" that you learn when working with type editors... :Whistling:</description><pubDate>Tue, 28 Nov 2006 09:43:14 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Anyway to expose ListView.Columns property?</title><link>http://forum.strataframe.net/FindPost4792.aspx</link><description>Perfect!  Thanks!</description><pubDate>Tue, 28 Nov 2006 09:17:32 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Anyway to expose ListView.Columns property?</title><link>http://forum.strataframe.net/FindPost4790.aspx</link><description>You'll probably have your best luck by setting the property to ReadOnly and add this attribute to the property:&lt;/P&gt;&lt;P&gt;&amp;lt;System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)&amp;gt; _&lt;/P&gt;&lt;P&gt;That tells the designer to "serialize" the columns into the InitializeComponent() method.</description><pubDate>Tue, 28 Nov 2006 09:06:14 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>