473,573 Members | 2,835 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Componen tModel
Friend Class JobDefSort
Inherits BaseSorter
Public Sub New()
SortOrder = New String() {"ID", "Name", "Descriptio n", "JobType",
"Run"}
End Sub
End Class

<TypeConverter( GetType(JobDefS ort))> _
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("J ob Definition ID."), Category("Syste m")> _
Public ReadOnly Property ID() As Long
Get
Return mID
End Get
End Property
<Description("J ob 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("J ob 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("J ob Type."), Category("Type" ), _
Editor(GetType( JobTypeEditor), GetType(UITypeE ditor))> _
Public Property Type() As JobType
Get
Return mType
End Get
Set(ByVal Value As JobType)
mType = Value
End Set
End Property
<Description("W hen 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.Componen tModel
Imports System.Text
Imports System.Globaliz ation
<TypeConverter( GetType(JobType Converter)), _
DefaultProperty Attribute("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(Optio nal 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("T ype."), Category("Data" )> _
Public ReadOnly Property Type() As eJobType
Get
Return mType
End Get
End Property
<Description("I nterval."), Category("Data" )> _
Public ReadOnly Property Interval() As Long
Get
Return mInterval
End Get
End Property
<Description("T ime."), Category("Data" )> _
Public Property Time() As Date
Get
Return mTime
End Get
Set(ByVal Value As Date)
mTime = Value
End Set
End Property
<Description("R ange."), Category("Data" )> _
Public ReadOnly Property Range() As String
Get
Return mRange
End Get
End Property
<Description("V alue."), Category("Data" )> _
Public ReadOnly Property Value() As String
Get
Return mValue
End Get
End Property
#End Region
End Class
Friend Class JobTypeConverte r
Inherits System.Componen tModel.Expandab leObjectConvert er
Protected SortOrder() As String
Public Overloads Overrides Function GetPropertiesSu pported( _
ByVal context As ITypeDescriptor Context) As Boolean
Return True
End Function
Public Overloads Overrides Function GetProperties(B yVal context As
ITypeDescriptor Context, _
ByVal value As Object, ByVal attributes() As Attribute) As
PropertyDescrip torCollection
Dim properties As PropertyDescrip torCollection = _
TypeDescriptor. GetProperties(v alue, 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.Componen tModel
Imports System.Windows. Forms.Design
Friend Class JobTypeEditor
Inherits UITypeEditor
Private _Service As IWindowsFormsEd itorService = Nothing
Public Overloads Overrides Function GetEditStyle(By Val context As
ITypeDescriptor Context) As UITypeEditorEdi tStyle
If Not context Is Nothing And Not context.Instanc e Is Nothing Then
Return UITypeEditorEdi tStyle.Modal
End If
Return MyBase.GetEditS tyle(context)
End Function
Public Overloads Overrides Function EditValue(ByVal context As
ITypeDescriptor Context, ByVal provider As IServiceProvide r, ByVal value As
Object) As Object
'Get a reference to the IWindowsFormsEd itorService used to display the
UILongString form
_Service = CType(provider. GetService(GetT ype(IWindowsFor msEditorService )),
IWindowsFormsEd itorService)
If Not _Service Is Nothing Then
'Create an instance of the custom UI form
Dim editor As JobTypeEdit = New JobTypeEdit
editor.Type = (context.Instan ce).Type
'Initialise the custom editor form with the current value of the target
Employee.Commen ts property
' editor.Val = (context.Instan ce).type
'Show the UILongString editor form
_Service.ShowDi alog(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.EditValu e(context, provider, value)
End Function
End Class

**JobTypeEdit.v b**
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 5554

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

Similar topics

9
3947
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 will not set the value of the control and will leave the checked status of the checkbox to false when a user selects a new date. this works fine...
0
1046
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 executed. what may be the reason? please help... I have written some code with in the set method of the expandable property.
10
7235
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 want to do something like this below.But I get a message Readonly is not valid property. foreach (Control ctl in pnlBenefits.Controls) { if (ctl is...
16
1896
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 can get this using: dim b as string b = DirectCast(myarraylist(0),myclass).myproperty However, I want to use an object to define the type "MyClass"...
2
2019
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 a use can expand it and set the properties. How do I do this? Thanks in advance.
6
2462
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 property grid? Thanks, Ron
1
1614
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 GridLines properties as my custom control subproperties, i used an expandable ExpandableObjectConverter class for my GridLineConverter.
1
1365
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 in the page where the user control is used. For that I defined a property as follows:
2
11034
by: johnlim20088 | last post by:
Hi Someone please help me string typ; if (e.Row.RowType == DataControlRowType.DataRow) { typ = e.Row.Cells.Text;
0
7784
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...
0
7704
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...
0
8031
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. ...
0
8073
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...
0
6424
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...
0
5294
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...
0
3735
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1309
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1044
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...

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.