473,699 Members | 2,834 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 1553

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

Similar topics

0
1336
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
1105
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 fieldType= new ComboBox(); private DataTable dtFieldType;
0
1497
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. Thanks in advance, Vlado
2
1308
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 be awesome thanks! ~benny
2
2441
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 am doing it wrong, any ideas what it is? Thanks in advance
0
1052
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
1048
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 to be one of my approved string values. Can somebody give me some pointers on this? It appears...
0
1143
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 which type it deals with. I then have TypeB, which derives from TypeA, but adds specific
7
3803
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 editor, is there any way to change this ?
0
8685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9171
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8880
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6532
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3053
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
2
2342
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.