473,398 Members | 2,165 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,398 software developers and data experts.

Using Property Grid in a control and Expandable types are always readonly

Hi all.

I'm using the Property Grid control in a control to manage a windows service
we have developed here. The windows service runs a set of other jobs that
need to be managed. The control is used to view the state of the running
jobs and schedule new jobs. The control also runs in the context of
Internet Explorer (we do this so the administrators of the jobs can always
receive the latest control). The property grid is used to change the
properties of the jobs (so we could add new properties w/o having to recode
the UI).

My problem is with the expandable object type. We're using this type to
represent some job properties that need to be set together and are defined
by a set of business rules. The type has a custom UITypeEditor and I do
know how to set that up and use it in VB. The problem is that when the
control is hosted in IE, this property type is readonly and cannot be
modified. It can't be expanded to look at the sub-properties and the
ellispsis button is not available to get the editor. When run in an exe,
everything works as it is supposed to: I get an expandable property, the
ellipsis button shows and works, and I can change values directly for my
expandable properties.

Has anyone run into this problem? This is really annoying us as the only
way to get full functionality of this control is to run it in an executable
which is not the ideal case for us since this is part of our overall
deployment strategy. Is there something that is missing that I should do?

I've posted snippets of my code below:

**JobDef.vb**
Imports System
Imports System.Drawing
Imports System.Drawing.Design
Imports System.ComponentModel
Friend Class JobDefSort
Inherits BaseSorter
Public Sub New()
SortOrder = New String() {"ID", "Name", "Description", "JobType",
"Run"}
End Sub
End Class

<TypeConverter(GetType(JobDefSort))> _
Friend Class JobDef
Implements IBrowsable
Private mID As Long
Private mName As String
Private mDescription As String
Private mType As JobType
Private mRun As Date = "01/01/2000"
Public Sub New()
mType = New JobType
mID = -1
End Sub
Public Sub New(ByVal ID As Long, ByVal Name As String, ByVal Description
As String, _
ByVal Type As Integer, ByVal Interval As Integer, ByVal Time As
Date, _
ByVal Value As String, ByVal Range As String, ByVal Run As Date)
mType = New JobType(Type, Interval, Range, Value, Time)
mID = ID
mName = Name
mDescription = Description
mRun = Run
End Sub

<Description("Job Definition ID."), Category("System")> _
Public ReadOnly Property ID() As Long
Get
Return mID
End Get
End Property
<Description("Job Definition name."), Category("Data")> _
Public Property Name() As String
Get
Return mName
End Get
Set(ByVal Value As String)
mName = Value
End Set
End Property
<Description("Job Definition Description."), Category("Data")> _
Public Property Description() As String
Get
Return mDescription
End Get
Set(ByVal Value As String)
mDescription = Value
End Set
End Property
<Description("Job Type."), Category("Type"), _
Editor(GetType(JobTypeEditor), GetType(UITypeEditor))> _
Public Property Type() As JobType
Get
Return mType
End Get
Set(ByVal Value As JobType)
mType = Value
End Set
End Property
<Description("When to start running this job."), Category("Data")> _
Public Property Run() As Date
Get
Return mRun
End Get
Set(ByVal Value As Date)
mRun = Value
End Set
End Property
End Class

**JobType.VB**
Imports System
Imports System.Drawing
Imports System.Drawing.Design
Imports System.ComponentModel
Imports System.Text
Imports System.Globalization
<TypeConverter(GetType(JobTypeConverter)), _
DefaultPropertyAttribute("Type")> _
Friend Class JobType
Public Enum eJobType
eONCE = 0
eMONTHLY_DOM = 1
eMONTHLY_DOW = 2
eWEEKLY = 3
eDAILY = 4
eINTERVAL = 5
End Enum
#Region "Variables"
Private mType As eJobType
Private mInterval As Integer
Private mTime As Date
Private mRange As String
Private mValue As String
#End Region
Sub New()
mType = eJobType.eONCE
mInterval = -1
mRange = vbNullString
mValue = vbNullString
mTime = System.DateTime.Now
End Sub
Sub New(ByVal Type As eJobType, ByVal Interval As Integer, _
ByVal Range As String, ByVal Value As String, ByVal Time As Date)
mType = Type
mInterval = Interval
mRange = Range
mValue = Value
mTime = Time
End Sub
Friend Sub SetValues(Optional ByVal Type As eJobType = eJobType.eONCE, _
Optional ByVal Interval As Integer = -1, _
Optional ByVal Range As String = vbNullString, _
Optional ByVal Value As String = vbNullString, _
Optional ByVal Time As Date = #1/1/2000#)
mType = Type
mInterval = Interval
mRange = Range
mValue = Value
mTime = Time
End Sub
#Region "Properties"
<Description("Type."), Category("Data")> _
Public ReadOnly Property Type() As eJobType
Get
Return mType
End Get
End Property
<Description("Interval."), Category("Data")> _
Public ReadOnly Property Interval() As Long
Get
Return mInterval
End Get
End Property
<Description("Time."), Category("Data")> _
Public Property Time() As Date
Get
Return mTime
End Get
Set(ByVal Value As Date)
mTime = Value
End Set
End Property
<Description("Range."), Category("Data")> _
Public ReadOnly Property Range() As String
Get
Return mRange
End Get
End Property
<Description("Value."), Category("Data")> _
Public ReadOnly Property Value() As String
Get
Return mValue
End Get
End Property
#End Region
End Class
Friend Class JobTypeConverter
Inherits System.ComponentModel.ExpandableObjectConverter
Protected SortOrder() As String
Public Overloads Overrides Function GetPropertiesSupported( _
ByVal context As ITypeDescriptorContext) As Boolean
Return True
End Function
Public Overloads Overrides Function GetProperties(ByVal context As
ITypeDescriptorContext, _
ByVal value As Object, ByVal attributes() As Attribute) As
PropertyDescriptorCollection
Dim properties As PropertyDescriptorCollection = _
TypeDescriptor.GetProperties(value, attributes)
Return properties.Sort(SortOrder)
End Function
Public Sub New()
SortOrder = New String() {"Type", "Interval", "Range", "Value", "Time"}
End Sub
'''
#Region "Variables"
#End Region
'''
#Region "Properties"
#End Region
End Class

**JobTypeEditor.VB**
Imports System
Imports System.Windows.Forms
Imports System.Drawing.Design
Imports System.ComponentModel
Imports System.Windows.Forms.Design
Friend Class JobTypeEditor
Inherits UITypeEditor
Private _Service As IWindowsFormsEditorService = Nothing
Public Overloads Overrides Function GetEditStyle(ByVal context As
ITypeDescriptorContext) As UITypeEditorEditStyle
If Not context Is Nothing And Not context.Instance Is Nothing Then
Return UITypeEditorEditStyle.Modal
End If
Return MyBase.GetEditStyle(context)
End Function
Public Overloads Overrides Function EditValue(ByVal context As
ITypeDescriptorContext, ByVal provider As IServiceProvider, ByVal value As
Object) As Object
'Get a reference to the IWindowsFormsEditorService used to display the
UILongString form
_Service = CType(provider.GetService(GetType(IWindowsFormsEdi torService)),
IWindowsFormsEditorService)
If Not _Service Is Nothing Then
'Create an instance of the custom UI form
Dim editor As JobTypeEdit = New JobTypeEdit
editor.Type = (context.Instance).Type
'Initialise the custom editor form with the current value of the target
Employee.Comments property
' editor.Val = (context.Instance).type
'Show the UILongString editor form
_Service.ShowDialog(editor)
'If the user has clicked on the OK button then the string they were editing
is returned to the property grid
Return editor.Type
End If
Return MyBase.EditValue(context, provider, value)
End Function
End Class

**JobTypeEdit.vb**
Imports System.Text
Friend Class JobTypeEdit
Inherits System.Windows.Forms.Form
Private mType As JobType
Private mbCancel As Boolean = True
#Region " Windows Form Designer generated code "
.... snipped ...
#End Region
#Region "Properties"
.... snipped ...
#End Region
#Region "Save"
.... snipped ...
#End Region
#Region "Load"
.... snipped ...
#End Region
#Region "Events"
.... snipped ...
#End Region
End Class

Thanks much.

Brian
Nov 20 '05 #1
0 5537

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

Similar topics

9
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
0
by: Pradeep | last post by:
Hi all, When i change an expandable property of an object from the property grid, the set method of that property is not being called, where as the set methods of its sub properties are being...
10
by: GP | last post by:
Is it possible to iterate through all the controls collection and make the textboxes alone as read only.I don't see a readonly property for the Control.Can some one help me in this context? I...
16
by: Dennis | last post by:
I have a class named "myclass" and an arraylist containing elements of type "MyClass". I want to get the value of a property of "MyClass" (a string type) for one of the arraylist elements. I...
2
by: Lespaul36 | last post by:
I have a control that I have made that uses a custom class for storage of some of the information. I want it to display in the VS.Net 2003 property grid in the IDE like the Font property does, so...
6
by: Ron M. Newman | last post by:
Hi, I have a problem with dynamically putting dynamic properties on the property grid. My app has no idea what it'll be showing at compile time. How do I dynamically add properties to the...
1
by: --== Alain ==-- | last post by:
Hi, I've created a simple class "GridLines" having 3 properties (Prop1, Prop2, and Prop3). in my custom control, i've created a property based on this class "GridLines". To show the...
1
by: shapper | last post by:
Hello, I am creating a user control where an Asp.Net control is used. It can be either a button, an image button or a label. I am trying to "expose" the Asp.Net control properties and events...
2
by: johnlim20088 | last post by:
Hi Someone please help me string typ; if (e.Row.RowType == DataControlRowType.DataRow) { typ = e.Row.Cells.Text;
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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...

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.