473,748 Members | 8,779 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 1560

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

Similar topics

0
1339
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
1108
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
1501
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
1312
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
2446
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
1055
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
1052
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
1148
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
3806
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
8989
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
8828
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9537
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...
1
9319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9243
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...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
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
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.