 |
|
 |
Why can't you just add this attribute?
[Editor(typeof(MultilineStringEditor),typeof(UITypeEditor))]
You will need to add the appropriate references to your project.
|
|
|
|
 |
|
 |
I have implemented a set of classes based on the example in the article and I have an issue that I wondered if you had any insight into.
If I pass a custom class as the "type" into the PropertySpec class, the propertygrid treats all the properties as readonly and seems to ignore my custom typeeditor and typeconverter that I am passing in.
I put breakpoints on the PropertyDescriptor::IsReadOnly() method it returns false. Most everything else seems to behave ok.
Any ideas?
-Jaz
www.sheetsofsound.net
|
|
|
|
 |
|
 |
It's only a guess but it might not be the isReadOnly that is working wrong here. Perhaps the grid sees the custom type editor, but theres something wrong with it, so it can't actually call it, so it doesn't know how to handle that specific type without the defined type editor.
Hope it helps.
|
|
|
|
 |
|
 |
If you comment out the case
Case "TheDescription"
Me.PropGridObj.Description = e.Value
in MyOwnClassBag_SetValue
you will notify that your example still works.
I found this out while debugging through a own piece of Code where I tried to use your technique and figured out that it doesn't write back anything since not setter is called.
Any suggestions ?
I'm also behind that, and will post if I have anny news on this issue
-Robert
|
|
|
|
 |
|
 |
Thanx for your comment,
it's a fault in MultiLineStringEditorForm.vb
The way it is now, it doesn't jump in the SetValue-function.
This is the way the MultiLineStringEditorFrom.vb should be:
'-----------------------------
Imports System.Text.RegularExpressions
Imports System.Windows.Forms
Public Class MultiLineStringEditorForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
' CUT
#End Region
Private Shared Form As New MultiLineStringEditorForm
Public Shared Sub Edit(ByRef InputValue As MultiLineString)
Form.MultiLineString = InputValue
If Form.ShowDialog() = Form.DialogResult.OK Then InputValue = Form.MultiLineString
End Sub
Public Shared Sub Edit(ByRef InputValue As MultiLineString, ByVal Title As String)
Form.Text = Title
Edit(InputValue)
End Sub
Public Property MultiLineString() As MultiLineString
Get
Return New MultiLineString(TextBox1.Text)
End Get
Set(ByVal Value As MultiLineString)
TextBox1.Text = Value.Value
End Set
End Property
End Class
'-----------------------------
|
|
|
|
 |
|
|
 |
|
 |
Can you show us how to do this in VB.NET using collections. (i.e. PropertyGrid for ListView and/or treeview, etc...)
|
|
|
|
 |
|
 |
I haven't done this myself yet, but in general it's all the same as in this example.
You have to write a custom typeeditor for your collection,
a converter and an editorform.
you pass the object to the form, make a copy of it, do whatever you want with the copy on that form, if user saves then the object that was passed to the form needs to be replaced with the (edited) copy.
if not saved, don't change the object, just close the form.
|
|
|
|
 |
|
 |
Could you include to that example also tiny database, please
Harri
|
|
|
|
 |
|
 |
I tried to e-mail you, but it bounced... send me an email with a valid return address plz
|
|
|
|
 |
|
 |
Something I stumbled upon the other night, just thought I might share it with you...
If you create a derived class, and set the DrawFlatToolbar property to True, you get the flat toolbars seen in the VS.NET IDE. The reason you must derive a class is that the DrawFlatToolbar property is marked as protected:
Public Class PropertyGridFlat
Inherits PropertyGrid
Public Sub New()
MyBase.New()
MyBase.DrawFlatToolbar = True
End Sub
End Class
There's your class... enjoy
-- Tom Spink, Über Geek.
|
|
|
|
 |
|
 |
Or you can just use Reflection - either way one has to ask why did they make it proetected and not public
|
|
|
|
 |
|
 |
This is true... and for anyone who's interested in using Reflection (as opposed to deriving a class), here's how you do it (make sure you have 'Imports System.Reflection' at the top of your code):
Dim pgGrid As PropertyGrid = PropertyGrid1 ' Change this to your property grid
pgGrid.GetType.GetProperty("DrawFlatToolbar", BindingFlags.NonPublic Or BindingFlags.Static Or BindingFlags.Instance).SetValue(pgGrid, True, Nothing)
Now, if that's a bit confusing, here it is as a few more lines:
Dim pgGrid As PropertyGrid = PropertyGrid1
Dim typGrid As Type = pgGrid.GetType
Dim piFlat As PropertyInfo = typGrid.GetProperty("DrawFlatToolbar", _
BindingFlags.NonPublic Or _
BindingFlags.Instance Or _
BindingFlags.Static)
piFlat.SetValue(pgGrid, True, Nothing)
-- Tom Spink, Über Geek.
|
|
|
|
 |