CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

MS SQL 2008 on ASP.NET Hosting
Free 3 Months



Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 6/4/2004 2:20:44 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 6 Views: 75 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
7 Items, 1 Pages 1 |< << Go >> >|
bugg
Asp.Net User
collection editor is not displaying object properties6/4/2004 2:20:44 AM

0/0

Hi,

I've created a simple server control that has a collection property. Here is how everything is set up:

- Collection property is defined as a collection of abstract class. Collection implements CollectionBase. Abstract class implements Control.
- Collection only has two types of items, which derive from that abstract class.
- Abstract class has two public string properties, so they are inherited by the items in the collection.
- I've also implemented a collection editor and overrode CreateNewItemTypes which returns an array of the only two types of items in the collection.

I can add and remove the two types of items in the collection editor just fine. However, it doesn't display the properties of these items. The only property I see is Value for Object. What could be wrong? This is my first time creating a server control, so it could be something very simple that I've overlooked. Any help is appreciated. Thanks.
master4eva
Asp.Net User
Re: collection editor is not displaying object properties6/4/2004 8:46:55 PM

0/0

:: Collection property is defined as a collection of abstract class.

Do you mean that you some code like this?

public abstract class MyCollection : CollectionBase {
// ...
}

Or did you mean by this:

public abstract class AbstractCollectionItem {
// ...
}

I need some verification before I can answer the question. Also, if possible, post some reproduction code because I am still a bit confused on other points that you made.
-- Justin Lovell
bugg
Asp.Net User
Re: collection editor is not displaying object properties6/4/2004 9:24:18 PM

0/0

Sorry for the confusion..

Here is the basic idea of what I have:
(I'll use fruits instead of what I actually have :)


//abstract collection item:
public abstract class Fruit : Control {
// this has these properties, for example:
public string Name {
get.. set..
}
public string Color {
get.. set..
}
}

//Actual collection items:
public class Apple : Fruit {
// ...
}

public class Orange : Fruit {
// ...
}


//Now the collection class:
public class Fruits : CollectionBase {
// Add... Remove...

public Fruit Item(int i) {
return (Fruit) List[i];
}
}

//Collection property in my main control:
[
ParseChildren(true),
PersistChildren(false)
]
public class FruitBasket : Control
{
private Fruits _items;
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.InnerProperty),
Editor(typeof(FruitBasketItemsEditor),
typeof(System.Drawing.Design.UITypeEditor)),
]
public Fruits Items
{
get
{
if(_items == null)
_items = new Fruits();
return _items;
}
}
}

//Now the collection editor:
public class FruitBasketItemsEditor : CollectionEditor
{
public FruitBasketItemsEditor(Type type) : base(type)
{
}
protected override Type[] CreateNewItemTypes()
{
return new Type[] {
typeof(Apple),
typeof(Orange)
};
}
}


I can add Apple and Orange to the collection using the collection editor. What I can't do is modify their properties using the collection editor. The only property I see is Value and it is read-only.
master4eva
Asp.Net User
Re: collection editor is not displaying object properties6/5/2004 7:29:19 AM

0/0

Ok, I see one thing missing (which I think is the key... and I bolded the addition):

public class FruitBasket : Control {
private Fruits _items;

[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.InnerProperty),
Editor(typeof(FruitBasketItemsEditor), typeof(System.Drawing.Design.UITypeEditor)),
NotifyParentProperty(true)
]
public Fruits Items {
get {
if(_items == null)
_items = new Fruits();

return _items;
}
}
}

That is the first thing that I saw... and tell me if that works or not. If it does not, I will have a quick breeze over your code again ;-) .

Cheers,
Justin
-- Justin Lovell
bugg
Asp.Net User
Re: collection editor is not displaying object properties6/5/2004 3:43:49 PM

0/0

Justin,

It did not help. Here is what I see in the collection editor:
http://img25.imageshack.us/img25/9301/coll_ed.jpg

As you can see, Name and Color properties are not displayed.

And here is all the code I am using (compacted a bit to not make it so long on the page):


using System;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Reflection;
using System.Collections;

namespace FruitBasket
{
//abstract collection item:
[ ToolboxItem(false) ]
public abstract class Fruit : Control {
// this has these properties, for example:
string _name, _color;
public string Color {
get { return (_color == null)?string.Empty:_color; }
set { _color = value; }
}
public string Name {
get { return (_name == null)?string.Empty:_name; }
set { _name = value; }
}
}

//Actual collection items:
public class Apple : Fruit {}
public class Orange : Fruit {}

//Now the collection class:
public class Fruits : CollectionBase {
public void Add(Fruit i) { List.Add(i); }
public void Remove(int i) { List.RemoveAt(i); }
public Fruit Item(int i) {
return (Fruit) List[i];
}
}

//Collection property in my main control:
[ ParseChildren(true),
PersistChildren(false) ]
public class FruitBasket : Control {
private Fruits _items;
[ DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.InnerProperty),
NotifyParentProperty(true),
Editor(typeof(FruitBasketItemsEditor),
typeof(System.Drawing.Design.UITypeEditor)) ]
public Fruits Items {
get {
if(_items == null)
_items = new Fruits();
return _items;
}
}
}

//Now the collection editor:
public class FruitBasketItemsEditor : CollectionEditor {
public FruitBasketItemsEditor(Type type) : base(type) {}
protected override Type[] CreateNewItemTypes() {
return new Type[] { typeof(Apple),
typeof(Orange) };
}
}
}


Thanks for the help.
master4eva
Asp.Net User
Re: collection editor is not displaying object properties6/5/2004 5:07:57 PM

0/0

Hmmm... just spotted another small gotcha :-) . Change the Fruits control to include the following code inside it (replaces your Item method):

public Fruit this[int index] {
get {
return (Fruit)List[index];
}
}

BTW - don't worry about making the page looking huge... I do not mind :-) .
-- Justin Lovell
bugg
Asp.Net User
Re: collection editor is not displaying object properties6/5/2004 5:58:01 PM

0/0

Justin,

That did it! Thank you very much for your help.
7 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Microsoft ADO. NET Professional Projects Authors: Sanjeev Rohilla, Senthil Nathan, Surbhi Malhotra, NIIT (Corporation), Pages: 968, Published: 2002
Pro ASP. Net 3. 5 Server Controls and AJAX Components Authors: Rob Cameron, Dale Michalk, Pages: 740, Published: 2008
CHI '92, Conference Proceedings: Striking a Balance Authors: Penny Bauersfeld, John Bennett, Gene Lynch, SIGCHI (Group : U.S.), ACM--SIGCAPH., Pages: 713, Published: 1992
Visual Basic 2005 Programmer's Reference Authors: Rod Stephens, Pages: 1022, Published: 2005
C# for Programmers: Updated for C# 2.0 Authors: Paul J. Deitel, Pages: 1317, Published: 2005
Visual C# 2005: How to Program Authors: Harvey M. Deitel, Paul J. Deitel, Pages: 1591, Published: 2006
Murach's VB.NET Database Programming with ADO.NET: Training & Reference Authors: Anne Prince, Doug Lowe, Pages: 585, Published: 2003
Visual Basic 2005: How to Program Authors: Harvey M. Deitel, Pages: 1513, Published: 2006
Developing Web Applications with Visual Basic.NET and ASP.NET Authors: John Alexander, Billy Hollis, Pages: 400, Published: 2002

Web:
CodeProject: Editing Multiple Types of Objects with Collection ... Feb 17, 2005 ... You may think why property does not return object instead of ... How do we tell the collection editor to display a dropdown image near the ...
CollectionEditor Class (System.ComponentModel.Design) If all of a class's properties are read-only, then CollectionEditor assumes ... packages the collection items in a wrapper object before displaying them in ...
PropertyGrid: Disable CollectionEditor without changing the Objec... I would like to disable the CollectionEditor inside the PropertyGrid. I'm not able to change the business object which is set as propertyGrid. ...
CodeProject: How to Edit and Persist Collections with ... Nov 26, 2003 ... NET 2.0) is to manage a collection of ToolStrips with some extra properties in design time with a standard or custom editor. I was not able ...
Developing a custom collection editor Last month, I needed custom collection editor at design-time, ... This function indicates PropertyGrid to display design-time editor type for this property. ...
How to Edit and Persist Collections with CollectionEditor--www ... Jun 30, 2005 ... CollectionEditor { protected override object CreateInstance(Type ... collection from the same window, by using a TreeView to display the ...
PropertyGrid: getting PropertyValueChanged notifications from a ... However, when the Collection Editor is closed, I do not get a ... and a listbox to the form and setting the listbox as the property grid's selected object. ...
MxDataGridField Collection Editor blank in new v. of Web Matrix ... I can manually edit the Select statement to not display the columns, ... ( Therefore I can't select an object or view it's properties) ...
InformIT: Safari Books Online - 9780137011797 - C# 2008 for ... Then, select the Images property in the Properties window to display the Image Collection Editor (Fig. 15.30). Here you can browse for images that you wish ...
Properties window - accessing collections - bytes This way still presents the button to display the editor, but it displays my grid not the default collection editor. My DataGridView is disabled for ...

Videos:
www.moldytoaster.com meant to say he had nearly got _under_ them--at all events the tunnel, when completed, will be a vast convenience to the metropolis, particularly ...
Core Patterns for Web Permissions Google TechTalks July 19, 2006 Tyler Close Visiting Scientist Hewlett-Packard Laboratories Mr. Close is a researcher and developer ...
Charlie Rose - Fouad Siniora / Miuccia Prada Segment 1: Guest host Jane Arraf of the Council on Foreign Relations talks to Fouad Siniora, Prime Minister of Lebanon. Segment 2: Guest host ...
www.moldytoaster.com re in a galaxy to some provincial Belle Vue-terrace or Prospect-place; where they endeavour to forestall the bachelors with promiscuous orange ...
www.moldytoaster.com COURT AND CITY. The other evening, the public were put in possession, at Covent Garden Theatre, of a new branch of art in play concoction ...
www.moldytoaster.com y and a biscuit." "Be it so; I will stay; I must do something to distract my thoughts." "You are like Debray, and yet it seems to me that when ...
Lies In The Textbooks - Creationist Kent Hovind Reveals The ... Lies In The Textbooks - Creation Scientist Kent Hovind Reveals The Truth Abut Evolution! For more videos like this please visit http://www.drdino ...




Search This Site:










problem with calling eventhandlers of custom datagrid.

creating a weighted array

can't access webcontrol.page from subclass

how to add a style property in cutomercontrol or usercontrol?

couple questions about custom controls with dynamically generated children controls

hosting need of asp 2.0 and sql 2005

using viewstate in a control

can i host invididual web applications in sub domains?

custom button control

webhosting plan

getting postback events to fire for dynamically added custom controls

ie webcontrols source code

getting my web form on the internet

referencing class from string

where to create applications under iis

i want to create custom color chooser controle

dropdownlist that doesn't load until it is clicked

customize smart tag..

user control that inherits the panel object

dropdownbox in properties

button property

lunarpages -- what do you think?

repeater with multiple itemtemplates

how can we enable the scroll bar for system.web.ui.webcontrols.treeview control?

how to write data to htmlinputhidden?

a looking for a 3rd party control that performs file uploads and downloads

tableitemstyle

clicking in custom controls

composite controls positioning

visual studio annotations, how to create?

  Privacy | Contact Us
All Times Are GMT