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

Have there been changes to Type Editors in .NET 2?

Hi

I've just upgraded some Type Editors from 1.1 to 2.0 and whilst they compile
OK, I'm not getting any results in the test harness PropertyGrid. Usually
when you select a particular property, the ellipsis appears at the end of the
cell and this is not heppening.

I was therefore wondering if there had been changes in TypeEditors between
..NET versions 1.1 and 2.0 that I hadn't hear about.

One of the Type Editors is shown below:

Imports System.Windows.Forms
Imports System.Drawing.Design
Imports System.ComponentModel

Public Class UIFilenameEditor
Inherits System.Drawing.Design.UITypeEditor
'@ <summary>Opens the dialogue in a modal window</summary>
'@ <remarks>
'@ <para>Since it is natural for the filename editor to open a file
dialogue which is a modal window, this editor is set to have Modal
style.</para>
'@ <para>This method seems to called when the cursor lands on a property
grid entry.</para>
'@ </remarks>
'@ <param name="context" type="ComponentModel.ITypeDescriptorContext">
'@ <para>The context is a
System.Windows.Forms.PropertyGridInternal.Property GridDescriptorGridEntry.</para>
'@ </param>
'@ <returns>Returns the 'style' to the calling property grid (or other
control)</returns>
Public Overloads Overrides Function GetEditStyle(ByVal context As
ITypeDescriptorContext) As UITypeEditorEditStyle
If Not context Is Nothing AndAlso Not context.Instance Is Nothing Then
Return UITypeEditorEditStyle.Modal
'
End If
Return UITypeEditorEditStyle.None
End Function
'@ <summary>Thid core method provides the file dialogue
interface.</summary>
'@ <returns>The file name that has been selected.</returns>
<RefreshProperties(RefreshProperties.All)> _
Public Overloads Overrides Function EditValue(ByVal context As
ITypeDescriptorContext, ByVal provider As System.IServiceProvider, ByVal
value As Object) As Object

If context Is Nothing OrElse provider Is Nothing OrElse
context.Instance Is Nothing Then
Return MyBase.EditValue(provider, value)
End If

Dim objFileDialogue As FileDialog

If context.PropertyDescriptor.Attributes(GetType(Save FileAttribute))
Is Nothing Then
objFileDialogue = New OpenFileDialog
Else
objFileDialogue = New SaveFileDialog
End If

objFileDialogue.Title = "Select " &
context.PropertyDescriptor.DisplayName
objFileDialogue.FileName = DirectCast(value, String)

Dim objFileDialogueFilterAttribute As FileDialogueFilterAttribute =
DirectCast(context.PropertyDescriptor.Attributes(G etType(FileDialogueFilterAttribute)), FileDialogueFilterAttribute)

If Not objFileDialogueFilterAttribute Is Nothing Then
objFileDialogue.Filter = objFileDialogueFilterAttribute.Filter
End If

Dim objFileDialogueCaptionAttribute As FileDialogueCaption =
DirectCast(context.PropertyDescriptor.Attributes(G etType(FileDialogueCaption)), FileDialogueCaption)

If Not objFileDialogueCaptionAttribute Is Nothing Then
objFileDialogue.Title = objFileDialogueCaptionAttribute.stuTitle
End If

If objFileDialogue.ShowDialog() = DialogResult.OK Then
value = objFileDialogue.FileName
End If

objFileDialogue.Dispose()

Return value
End Function
'@ <summary>An attribute class within UIFilenameEditor that sets the
filter on the file dialogue.</summary>
<AttributeUsage(AttributeTargets.Property)> _
Public Class FileDialogueFilterAttribute
Inherits Attribute
Private _stuFilter As String

'@ <summary>The filter to use in the file dialog in
UIFilenameEditor.</summary>
'@ <remarks>The following is an example of a stuFilter string: "Text
files (*.txt)|*.txt|All files (*.*)|*.*"</remarks>
Public ReadOnly Property Filter() As String
Get
Return _stuFilter
End Get
End Property

'@ <summary>Define a Filter for the UIFilenameEditor.</summary>
'@ <param name="stuFilter">The filter string to use in the file
dialog in UIFilenameEditor. The following is an example of a filter string:
"Text files (*.txt)|*.txt|All files (*.*)|*.*"</param>
Public Sub New(ByVal stuFilter As String)
MyBase.New()
_stuFilter = stuFilter
End Sub
End Class

'@ <summary>An attribute class within UIFilenameEditor that, if present,
changes the <i>open file dialogue</i> to a <i>save file dialogue</i>
control</summary>
<AttributeUsage(AttributeTargets.Property)> _
Public Class SaveFileAttribute
Inherits Attribute
End Class

'@ <summary>An attribute that sets the caption on the file dialogue
box</summary>
<AttributeUsage(AttributeTargets.Property)> _
Public Class FileDialogueCaption
Inherits Attribute

Private _stuCaption As String

'@ <param name="stuTitle">The string that will be placed in the
title bar of the dialogue</param>
Public Sub New(ByVal stuTitle As String)
_stuCaption = stuTitle
End Sub

Public ReadOnly Property stuTitle() As String
Get
Return _stuCaption
End Get
End Property

End Class
End Class

I created a test class to exercise each of the Type Editors that I've
written. The corresponding property in the test class is:

Private _stuFilename As String

<Category("File editors"), EditorAttribute(GetType(UIFilenameEditor),
GetType(UITypeEditor)), UIFilenameEditor.FileDialogueFilter("HTML
files|*.htm"), UIFilenameEditor.FileDialogueCaption("Select an HTML file")> _
Public Property stuFilename() As String
Get
Return _stuFilename
End Get
Set(ByVal stuFilename As String)
_stuFilename = stuFilename
End Set
End Property
Any clues anyone?

Thanks in advance.

Crispin

Bristol, UK.
Jun 18 '06 #1
0 1654

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

Similar topics

3
by: Alessandro Crugnola *sephiroth* | last post by:
Hi, i'm using wxPython and wxTextStyled. How can I intercept document changes for active documents (for example modified with others external editors)? thanks in advance -- Alessandro...
5
by: bittercold | last post by:
Hi, guys, I need to overload global "new" operator but I have to know the type id "new" is begin invoked on. For example if I overload it like this void *operator new(size_t n) { ...body......
4
by: frogman042 | last post by:
My daughter is playing around trying to learn JavaScript and she wrote a small program that prints out a message in increasing and decreasing font size and color changes. She is using document...
21
by: windandwaves | last post by:
Hi Folk Right now, I am using notepad2 to edit my PHP files. Do you have any recommendations for any php editors I should purchase instead? I dont mind spending some money for a good product....
0
by: Lars Eighner | last post by:
Follow up in comp.editors The followup to this message (in comp.editors) contains the whole version 1.0 distrution of Type HTML Macros for JOE. This is a flat ASCII document, but it runs to...
28
by: rich | last post by:
i know that there are die hard mark uppers that use notepad or some other plain editors...as far as graphic editors are concerned what are some reccomendations both commercial and if any freeware
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
13
by: so many sites so little time | last post by:
say i want spacing in my text so instead of doing <br> <br> in between the lines or having to do <href = or <a href = for a link what could i do to have php enter to mysql or retrive it formated?
19
by: zzw8206262001 | last post by:
Hi,I find a way to make javescript more like c++ or pyhon There is the sample code: function Father(self) //every contructor may have "self" argument { self=self?self:this; ...
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?
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
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,...
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
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,...
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.