473,385 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Frustrating problem with CollectionEditor - invoking another editor

Hi.
I have a problem using the CollectioEditor.
In my custom control I have a public property that returns ItemList.
ItemList is inherited from CollectionBase and contains very simple
items
called "TestItem" that are inherited from Control.
i have added,To the TestItem class, a proprety called "ItemIcon",
and I added to this property the attribute
Editor(typeof(ImageUrlEditor)....).
In design-time, I can access the "ItemList" property and add a
"ItemIcon"
item to the collection and then change the "ItemIcon" property.
Now begins the problem:
my problem happens in 2 cases:
1)I change to html view and back to design view.
2) I simply run the application, and then return to deisgn view
(after I exit the application).

The problem is that now, when I access the "ItemList" property and try
to press on the 3 dots of the ImageUrlEditor of "ItemIcon" nothing
happens.
I really don't know how to solve this problem.
please help.

here is my code:

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.Collections;
using MyWebControls;

namespace MyWebControls
{
/// <summary>
/// Implementation of an ASP.NET Context Menu control
/// </summary>
[ToolboxData("<{0}:Test runat=server></{0}:Test>"),
Designer(typeof(MyDesigner)),
ParseChildren(true,"Items")
]
public class Test : System.Web.UI.WebControls.WebControl
{
private ItemList _items=new ItemList();

[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)]
[PersistenceMode(PersistenceMode.InnerDefaultProper ty)]
public ItemList Items
{
get {return _items; }
}

/// <summary>
/// Render this control to the output parameter specified.
/// </summary>
/// <param name="output"> The HTML writer to write out to </param>
protected override void Render(HtmlTextWriter output)
{
output.WriteBeginTag("IMG");
output.WriteAttribute("src",Items[0].ItemIcon);
output.WriteEndTag("IMG");
base.Render(output);

}

}

public class MyDesigner : ControlDesigner
{
#region Overriden methods

/// <summary>
/// Returns HTML code to show in designer
/// </summary>
public override string GetDesignTimeHtml()
{
return "<div style=\"padding:2px; background-color:
ButtonFace;color:ButtonText; "+
"border-style:outset; border-width:1px; font: 75% 'Microsoft Sans
Serif';\"><b>"+
"Test Control</b> - "+((Control)Component).ID+"</div>";
}

#endregion
}
#region Menu Items Class and The Menu Items Collection

[ToolboxItem(false)]
public class TestItem : Control
{
private string iconUrl=string.Empty;

[Editor(typeof(System.Web.UI.Design.ImageUrlEditor) ,
typeof(System.Drawing.Design.UITypeEditor))]
public string ItemIcon
{
get { return iconUrl; }
set { iconUrl=value; }
}

public TestItem()
{
}
}

public class ItemList : CollectionBase
{

public TestItem this[int Index]
{
get
{
return (TestItem) List[Index];
}
set
{
List[Index]=value;
}
}

public int Add(TestItem value )
{
return( List.Add( value ) );
}
public int IndexOf(TestItem value )
{
return( List.IndexOf( value ) );
}

public void Insert( int index, TestItem value )
{
List.Insert( index, value );
}

public void Remove(TestItem value )
{
List.Remove( value );
}

public bool Contains(TestItem value )
{
// If value is not of type TestItem, this will return false.
return( List.Contains( value ) );
}

protected override void OnInsert(int index, object value)
{
base.OnInsert (index, value);
}
}

#endregion

}
Nov 18 '05 #1
0 1537

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Buzz Bonner | last post by:
Hi, I need to perform some validation on the items inserted into the CollectionEditor. How can I override the CollectionEditor OK button so that the editor doesn't close if a validation error is...
1
by: Lucas Sain | last post by:
Hi, I'm trying to create a property in a class that should be apepar as dropdown combo at design time with X options. Something like the WindowStateProperty where you can select 3 options. How...
0
by: Vlado Brlečić | last post by:
Hello everyone! Can anyone tell me where can I catch the closing of CollectionEditorForm? I would like to do something after all items are added in collection and ok button on collectionEditor's...
2
by: Benny Raymond | last post by:
I'm working on a program that has a treeview, and each tree node refrences a row in my database. I really like how the properties section of the collections editor looks - is this a control that...
2
by: AMDRIT | last post by:
Hello everyone, I have created a custom component and one of its properties is a class object with it's own properties. During runtime, I can assign values to the class object properties just...
0
by: Henry J. | last post by:
Is there a way to find the element currently selected in a CollectionEditor where a collection is displayed? For PropertyGrid one can use something like SelectedGridItems to get the currently...
0
by: Brannon | last post by:
I have a TypeConverter that displays an exclusive list of possible strings for a certain string property. That works great. In a different class, I have a list of strings with the same limitation....
0
by: Bardo | last post by:
Hi all, I am having an issue with a custom CollectionEditor. My scenario is as follows: I have a base type TypeA. I also have a TypeACollection. The TypeACollection has an Editor attribute of...
7
by: colin | last post by:
Hi, I have my property editor wich uses the pop up collection editor for arrays etc, but i have had to use a generic wrapper for the elements in some types of collections. although the editing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.