473,569 Members | 2,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Frustrating problem with CollectionEdito r - 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(I mageUrlEditor). ...).
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.D esign;
using System.Web.UI.W ebControls;
using System.Componen tModel;
using System.Componen tModel.Design;
using System.Collecti ons;
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(t rue,"Items")
]
public class Test : System.Web.UI.W ebControls.WebC ontrol
{
private ItemList _items=new ItemList();

[DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.Content)]
[PersistenceMode (PersistenceMod e.InnerDefaultP roperty)]
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(HtmlText Writer output)
{
output.WriteBeg inTag("IMG");
output.WriteAtt ribute("src",It ems[0].ItemIcon);
output.WriteEnd Tag("IMG");
base.Render(out put);

}

}

public class MyDesigner : ControlDesigner
{
#region Overriden methods

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

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

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

[Editor(typeof(S ystem.Web.UI.De sign.ImageUrlEd itor),
typeof(System.D rawing.Design.U ITypeEditor))]
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(TestIte m 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(TestIt em 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 1543

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

Similar topics

0
1313
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 raised?
1
1097
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 can this be done I've tried several ways but can't get it to work. Whta am I doing wrong?. This is what I have in the class private ComboBox...
0
1492
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 form is pressed. I tried in CollectionBase's overrides OnInsert, and OnInsertComplete but they are called for each item. I hope I was clear enough....
2
1299
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 is available to use? I thought it was a datagrid, but I can't get the datagrid to show up like the collections properties thing. Any help would...
2
2427
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 fine. However, when attempting to assing default values as designtime in the propertygrid, nothing is working on the class object. I know that I...
0
1041
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 selected property in a PropertyGrid. But I failed to find anything for the selected element in a CollectionEditor. Thanks for any tips!
0
1040
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. I want a CollectionEditor that will limit the string values to those of my converter and limit the list so that its entries are unique and forced...
0
1128
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 TypeACollectionEditor. This collection editor derives from the framework CollectionEditor, passing TypeACollection in the constructor to indicate...
7
3793
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 actually works well, and I can set the name ok in the primary property editor, this makes a mess of the type name displayed in the pop up colection...
0
7612
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7968
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.