473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

collectionEditor 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 : "editorStyle" and "events".
The first property is used to select one of a series of web controls. The
second one opens a collectioneditor 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 "editorStyle" 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_dropdownlist = 3
es_bound_checkboxlist = 5
es_bound_radiobuttonlist = 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("CollectionEditor", "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
collectionEditor
Public Class ControlEvent

Private _command As String
Private _event As Object

<TypeConverter(GetType(EventConverter))> _
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(Item)
End Sub
End Class

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

Private Shared events As StandardValuesCollection

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.Label)
Case 2
myTypeEvent = GetType(System.Windows.Forms.TextBox)
Case 3
myTypeEvent = GetType(System.Windows.Forms.ComboBox)
Case 5
myTypeEvent = GetType(System.Windows.Forms.CheckBox)
Case 7
myTypeEvent = GetType(System.Windows.Forms.RadioButton)
End Select

Dim events_info As System.Reflection.EventInfo() =
myTypeEvent.GetEvents

ReDim Preserve eventNames(events_info.Length - 1)

For i = 0 To events_info.Length - 1
eventNames(i) = events_info(i).Name
Next
events = New StandardValuesCollection(eventNames)

Catch ex As Exception
' myMessageBox(ex.Message, "manipulateData - fillPropertyGrid",
MessageBoxButtons.OK, MessageBoxIcon.Error)

End Try
End Sub

Public Overloads Overrides Function GetStandardValuesSupported(ByVal
context As ITypeDescriptorContext) As Boolean
Return True
End Function 'GetStandardValuesSupported

Public Overloads Overrides Function GetStandardValuesExclusive(ByVal
context As ITypeDescriptorContext) As Boolean
Return True
End Function 'GetStandardValuesExclusive

Public Overloads Overrides Function GetStandardValues(ByVal context As
ITypeDescriptorContext) As StandardValuesCollection
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.Label)
should look something like : myTypeEvent =
GetType(System.Web.UI.WebControls.Label)

My problem is that System.Web.UI.WebControls.Label 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 "editorStyle" property the es_label and i open the "events"
collectionEditor, 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 collectionEditor (instead of the button's events)

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

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

Similar topics

2
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...
0
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...
0
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...
0
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....
0
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...
0
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...
0
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...
2
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...
0
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...
7
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.