 |
|
 |
Why can't you just add this attribute?
[Editor(typeof(MultilineStringEditor),typeof(UITypeEditor))]
You will need to add the appropriate references to your project.
|
| Sign In·View Thread·PermaLink | 1.00/5 (2 votes) |
|
|
|
 |
|
 |
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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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 '-----------------------------
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Can you show us how to do this in VB.NET using collections. (i.e. PropertyGrid for ListView and/or treeview, etc...)
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
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.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
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.
|
| Sign In·View Thread·PermaLink | 4.50/5 (2 votes) |
|
|
|
 |
|
 |
Or you can just use Reflection - either way one has to ask why did they make it proetected and not public
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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.
|
| Sign In·View Thread·PermaLink | 5.00/5 (2 votes) |
|
|
|
 |