473,651 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

collectionEdito r re-initialize

Hello all,
here is my problem. I am using a property grid control (in a vb.net 2003
project) in which two properties are exposed : "editorStyl e" and "events".
The first property is used to select one of a series of web controls. The
second one opens a collectionedito r which also exposes two properties :
"event" and "command". The "event" property is a combobox that is filled with
the events of the control that was selected in the "editorStyl e" property
(so, if we select a label, the label's events are used to fill the "event"
property; if a button is selected , the button's events are used to fill the
"event" property ,etc. ). The "command" property is clear text.

To achieve that i have come up with the following code (by moving parts from
internet downloaded code)

Public Class colProperties

'type of editor
Public Enum editorStyleEnum
es_label = 1
es_textbox = 2
es_bound_dropdo wnlist = 3
es_bound_checkb oxlist = 5
es_bound_radiob uttonlist = 7
End Enum

Private y As ControlEvents
Private _editorStyle As editorStyleEnum

Public Property editorStyle() As editorStyleEnum
Get
editorStyle = _editorStyle
columnType = _editorStyle
End Get
Set(ByVal Value As editorStyleEnum )
_editorStyle = Value
End Set
End Property

<Editor("Collec tionEditor", "UITypeEditor") > _
Public Property events() As ControlEvents
Get
events = y
End Get
Set(ByVal Value As ControlEvents)
y = Value
End Set
End Property

End Class

'this is the class, the properties of which are exposed in the
collectionEdito r
Public Class ControlEvent

Private _command As String
Private _event As Object

<TypeConverter( GetType(EventCo nverter))> _
Public Property eventNames() As String
Get
eventNames = _event
End Get
Set(ByVal Value As String)
_event = Value
End Set
End Property

Public Property command() As String
Get
Return Me._command
End Get
Set(ByVal Value As String)
Me._command = Value
End Set
End Property

Public Sub New()
Me._command = ""
End Sub
End Class

'this is the class of a collection of controlEvent objects
Public Class ControlEvents
Inherits CollectionBase

'Retrieves an item from the collection by index
Default Public Property Item(ByVal Index As Integer) As ControlEvent
Get
Return CType(list.Item (Index), ControlEvent)
End Get
Set(ByVal Value As ControlEvent)
list.Item(Index ) = Value
End Set
End Property

'Adds an item to the collection
Public Function Add(ByVal Item As ControlEvent) As Integer
Return list.Add(Item)
End Function

Public Sub Remove(ByVal Item As ControlEvent)
list.Remove(Ite m)
End Sub
End Class

'this class is used to fill the "event" property of the collectionEdito r
'using the <TypeConverter( GetType(EventCo nverter))> attribute
Friend Class EventConverter
Inherits StringConverter

Private Shared events As StandardValuesC ollection

Public Sub New()
Try

Dim myTypeEvent As Type

Dim i As Int16, eventNames As String()
Select Case columnType 'this is declared in a module (as public)
Case 1
myTypeEvent = GetType(System. Windows.Forms.L abel)
Case 2
myTypeEvent = GetType(System. Windows.Forms.T extBox)
Case 3
myTypeEvent = GetType(System. Windows.Forms.C omboBox)
Case 5
myTypeEvent = GetType(System. Windows.Forms.C heckBox)
Case 7
myTypeEvent = GetType(System. Windows.Forms.R adioButton)
End Select

Dim events_info As System.Reflecti on.EventInfo() =
myTypeEvent.Get Events

ReDim Preserve eventNames(even ts_info.Length - 1)

For i = 0 To events_info.Len gth - 1
eventNames(i) = events_info(i). Name
Next
events = New StandardValuesC ollection(event Names)

Catch ex As Exception
' myMessageBox(ex .Message, "manipulate Data - fillPropertyGri d",
MessageBoxButto ns.OK, MessageBoxIcon. Error)

End Try
End Sub

Public Overloads Overrides Function GetStandardValu esSupported(ByV al
context As ITypeDescriptor Context) As Boolean
Return True
End Function 'GetStandardVal uesSupported

Public Overloads Overrides Function GetStandardValu esExclusive(ByV al
context As ITypeDescriptor Context) As Boolean
Return True
End Function 'GetStandardVal uesExclusive

Public Overloads Overrides Function GetStandardValu es(ByVal context As
ITypeDescriptor Context) As StandardValuesC ollection
Return events
End Function

End Class 'EventConverter
=============== =============== =============== =======

I am facing two problems
a. In the New Sub of the EventConverter class, instead of windows controls i
want to get the type of web controls. So the line : myTypeEvent =
GetType(System. Windows.Forms.L abel)
should look something like : myTypeEvent =
GetType(System. Web.UI.WebContr ols.Label)

My problem is that System.Web.UI.W ebControls.Labe l is not an option (perhaps
cos i am developing a vb.net project). How can i get the type of web controls
?

b. The New sub of the EventController class is run only once. So if i select
the in the "editorStyl e" property the es_label and i open the "events"
collectionEdito r, then the "event" property should be filled in with the
labels events. If i then change my selection and chooce textbox then the New
sub is not run again, and so the label's events are still shown in the
"event" property of the collectionEdito r (instead of the button's events)

My apologies for the lengthy email
thx a lot
theodore
Nov 23 '05 #1
0 1561

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

Similar topics

2
492
by: m. pollack | last post by:
Hi all I've been using the PropertyGrid to allow the user to edit a class object at runtime. The class object contains a custom strongly-typed collection, and I have written a subclass of CollectionEditor to manipulate it, using an EditorAttribute on the collection class to associate the collection with my custom Editor subclass. The Collection Editor has its own little PropertyGrid, which displays the properties of the selected member of the...
0
1356
by: m. pollack | last post by:
<I've reposted this here as it was slipping away over the horizon on the C# group Hi all, I've been writing an application that uses a class object (call it Element) that I need to expose to the user at runtime for editing. To do this, I've been using the PropertyGrid control. The Element object has a collection property that contains references to other Elements (its purpose is to allow the users to generate XML schemas at runtime, in...
0
1330
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?
0
1609
by: m. pollack | last post by:
Hi all I've been writing an application that uses a class object (call it Element) that I need to expose to the user at runtime for editing. To do this, I've been using the PropertyGrid control. The Element object has a collection property that contains references to other Elements (its purpose is to allow the users to generate XML schemas at runtime, in which elements can be nested to arbitrary depth). The PropertyGrid control opens an...
0
1227
by: m. pollack | last post by:
<I've reposted this as it was slipping away over the horizon Hi all, I've been writing an application that uses a class object (call it Element) that I need to expose to the user at runtime for editing. To do this, I've been using the PropertyGrid control. The Element object has a collection property that contains references to other Elements (its purpose is to allow the users to generate XML schemas at runtime, in which elements can be...
0
1374
by: Bill Gauvey | last post by:
I have a class that works great within the propertygrid with an exception of one member. It is a collection of a simple class objects that I have. I have tried everything but cant get the class to display in the CollectionEditor. What does it take to get the class to display in the CollectionEditor? Thanks,
0
1587
by: Andreas | last post by:
Hi! I'm using a custom collection with custom items to be edited with a custom CollectionEditor. This set of functionality is to be a part of a plugin for a SharpDevelop-based application. The strange thing now is that my derived CollectionEditor's SetItems method is called when testing the collection editing within a small test application, but is NOT called when tested from within the SharpDevelop environment. Thus whenever I add...
2
2378
by: Henry J. | last post by:
Has anybody run into this index out range exception when opening and then closing a collectionEditor from within a PropertyGrid? I use PropertyGrid to edit configurations in my application. One of the fields is a collection. I can expand or collapse the collection in the PropertyGrid fine. However,if I open the CollectionEditor associated with the collection, do nothing, and just close it, I get an index out of range error. Note...
0
1139
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
3801
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
8349
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
8275
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,...
1
8460
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
8576
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
7296
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
6157
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
5609
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4281
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1906
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.