473,721 Members | 2,201 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 1565

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
1357
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
1337
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
1616
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
1230
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
1376
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
1591
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
2382
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
1146
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
3805
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
8738
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
9150
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,...
1
6678
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
5994
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
4501
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
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
2599
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2146
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.