StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      


12»»

Anyway to expose ListView.Columns property?Expand / Collapse
Author
Message
Posted 11/28/2006 1:37:10 AM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: Today @ 11:34:55 AM
Posts: 1,327, Visits: 3,472
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).

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:

For each col As ColumnHeader in value
Me.lvwAny.Columns.Add(col)
Next col

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).

Any ideas on how I might do this?
Post #4788
Posted 11/28/2006 9:06:14 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 11:24:42 AM
Posts: 2,686, Visits: 1,889
You'll probably have your best luck by setting the property to ReadOnly and add this attribute to the property:

<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)> _

That tells the designer to "serialize" the columns into the InitializeComponent() method.


www.bungie.net
Post #4790
Posted 11/28/2006 9:17:32 AM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: Today @ 11:34:55 AM
Posts: 1,327, Visits: 3,472
Perfect! Thanks!
Post #4792
Posted 11/28/2006 9:43:14 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 11:24:42 AM
Posts: 2,686, Visits: 1,889
Not a problem... that's one of the first "gotchas" that you learn when working with type editors...


www.bungie.net
Post #4793
Posted 11/28/2006 11:14:16 AM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: Today @ 11:34:55 AM
Posts: 1,327, Visits: 3,472
OK, I must have moved onto the second gotcha ...

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).

You have any idea of what going on here?
Post #4802
Posted 11/28/2006 11:32:05 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 11:24:42 AM
Posts: 2,686, Visits: 1,889
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?


www.bungie.net
Post #4805
Posted 11/28/2006 11:43:53 AM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: Today @ 11:34:55 AM
Posts: 1,327, Visits: 3,472
When I attempt to open the type editor I get an error. I've attached a screen shot of the message box.

  Post Attachments 
ToolStripItems_TypeEditorError.bmp (19 views, 180.69 KB)
Post #4808
Posted 11/28/2006 1:58:40 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 11:24:42 AM
Posts: 2,686, Visits: 1,889
I'm not sure... I'll have to test this.  That's not our type editor, though... it's .NET's type editor.


www.bungie.net
Post #4826
Posted 11/28/2006 2:07:26 PM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: Today @ 11:34:55 AM
Posts: 1,327, Visits: 3,472
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.
Post #4828