Has anyone an idea how to achieve this with OpenEdge code?
I have found some C# and VB samples but those samples are using properties I can't find in 'my world'.
Probably because you need to add some extra assembly references.
Which properties are you looking for ?
I have to create a new RadButton (this part is ok of course) and add this button as a child element to a valueItem of the propertyGrid. The button has to be visible all the time, so not only when the value is edited.
I need something like this: Me.ValueElement.Children.Add(myButton).
Take a look at www.telerik.com/.../propertygrid-custom-items.html
Instead of the radiobuttonelement, use the RadButtonElement (do not use RadButton)
I think I expressed myself in the wrong way ...
What I want to do is write a custom editor class (in my case a custom PropertyGridButtonEditor) and use this custom editor in the _editorRequired event of my propertyGrid. Something like:
e:EditorType = Progress.Util.TypeHelper:GetType("PropertyGridButtonEditor").
I still get errors on this statement because I assume there is something wrong in my PropertyGridButtonEditor class.
Two possible causes :
1. Is your PropertyGridButtonEditor a class in the root directory ? If not -> are you using a using statement ?
I personally don't like using statement and always use the fully referenced class name (package + class)
2. are the EditorType and the result of the GetType of the same type ? Maybe you need an extra cast
In my project this works fine :
Custom Editor :
----------------------
using Progress.Lang.*.
using Telerik.WinControls.UI.BaseInputEditor.
block-level on error undo, throw.
class RadPropertyGrid.PropertyGridButtonEditor inherits BaseInputEditor:
define override public property DataType as System.Type
get.
method override protected Telerik.WinControls.RadElement CreateEditorElement( ):
undo, throw new Progress.Lang.AppError("METHOD NOT IMPLEMENTED").
end method.
end class.
In form where radpropertygrid is used :
@VisualDesigner.
method private void radPropertyGrid1_EditorRequired( input sender as System.Object, input e as Telerik.WinControls.UI.PropertyGridEditorRequiredEventArgs ):
e:EditorType = Progress.Util.TypeHelper:GetType("RadPropertyGrid.PropertyGridButtonEditor").
return.
end method.
I completely agree that using the fully referenced class name makes code more readable so I avoid the 'using' statement in my code.
I have compared your code with the code I am using and we are doing exactly the same!
It looks like the editorRequired statement executes fine, but afterwards an error is shown:
System.ArgumentNullException: value cannot be null.
Am I missing something in the form where I use the radPropertyGrid?
Can you do me a favour and attach a screenshot of your application where u use this custom editor?
I would like to see the final result.
Sorry, but I'm missing the whole thing.
1. I don't understand this event and why you need to fill in the Type in the args object. But I guess that is my problem! The doc doesn't seem to explain it.
2. You are trying to get the System.Type of the current class (THIS-OBJECT), right?. Why don't you just call THIS-OBJECT:GetType(). You shouldn't need the Helper.
It is not the type of the current class but the type of the custom editor where you want eg. to replace the integer field with a slider
I didn't try to run it :)
I got no compile error, and I thought that's what you were getting
If I run it, I do get a runtime error, the same a you from the moment I click on it
Hmmm ... it looks like we are getting the same result: nothing :-)
Are you using OE11.5 or 11.6?
I am still on OE11.5 on the environment where I am testing it, so I hoped a little bit that you didn't have the problem because you were on OE11.6
I think I will log another call with tech support :-)
11.6 64 bit and Telerik version 2016.Q1
And still the same result: not good :-)
Re: It is not the type of the current class but the type of the custom editor where you want eg. to replace the integer field with a slider:
OK. That makes sense as a concept. But I thought this IS the customer editor class. And if it's not this class, why am I seeing that the name in the GetType call is RadPropertyGrid.PropertyGridButtonEditor which is the same as the name of the ABL class that I'm in: RadPropertyGrid.PropertyGridButtonEditor.
If PropertyGridButtonEditor is an ABL class, not a .NET class, you can't get a Type for an ABL class via the Helper. Though GetType() on the instance will give you something, since that will call GetType() on the .NET proxy for your ABL class.
Laura, is it possible to write a simple sample that uses a custom editor class?
Laura, in the code above there is the class RadPropertyGrid.PropertyGridButtonEditor
The bottom part of the code is the method of the EditorRequired from the form (or in my case an ABL user control)
What should be used then instead of code below ?
e:EditorType = Progress.Util.TypeHelper:GetType("RadPropertyGrid.PropertyGridButtonEditor")
Sorry - I've never used these controls and don't know how to use them - which should be obvious by my previous answers!
In the code there are 2 pieces ...
one with the class
using Progress.Lang.*. using Telerik.WinControls.UI.BaseInputEditor. block-level on error undo, throw. class RadPropertyGrid.PropertyGridButtonEditor inherits BaseInputEditor: define override public property DataType as System.Type get. method override protected Telerik.WinControls.RadElement CreateEditorElement( ): undo, throw new Progress.Lang.AppError("METHOD NOT IMPLEMENTED"). end method. end class.
and the other is the method in the form :
@VisualDesigner. method private void radPropertyGrid1_EditorRequired( input sender as System.Object, input e as Telerik.WinControls.UI.PropertyGridEditorRequiredEventArgs ): e:EditorType = Progress.Util.TypeHelper:GetType("RadPropertyGrid.PropertyGridButtonEditor"). return. end method.
The question remains : how must the type be returned in EditorRequire method ?
I think I've already explained about using THIS-OBJECT:GetType(), but that presumes that that is what you want to do. And I'm not at all sure it is based on the comment by gdb390. You need to explain to me in English what you are trying to do by this line - at a high level. What object are you trying to get the Type of?
Laura, no problem, you can't know it all ;)
Evy, are you going to log it with TS , please keep me informed
No one addressed my previous post - is the object you are trying to get the Type of the custom class written in the ABL? If it is, then you need to do what I said. It wouldn't be THIS-OBJECT:GetType() as now you've explained that that code is the form, not the custom class itself. But you must have an instance of the custom class (RadPropertyGrid.PropertyGridButtonEditor). Call GetType() on that instance. As I explained, you can only use the Helper on pure .NET classes - not on an ABL class that inherits from .NET.
yes, we need the type of the custom class written in ABL
I'll try some things out this week
Hi Laura,
I think I understand what you mean and I tried it on the sample gdb provided.
I do something like this in the radPropertyGrid1_EditorRequired method:
define private variable mybuttonEditor as RadPropertyGrid.PropertyGridButtonEditor no-undo.
mybuttonEditor = new RadPropertyGrid.PropertyGridButtonEditor().
e:EditorType = buttonEditor:getType().
This code compiles but if I run it I get another error:
System.InvalidOperationException: calling method
CreateEditorElement
Followed by:
A .Net object is attempting to access a method or property of an ABL/.net hybrid class that already been deleted.
Any idea on this?
It would help if you turned on debugalert (either -debugalert or session:debug-alert = yes) and look at the stack trace you get when this error comes up.
I'm not sure if it has anything to do with the fact that your CreateEditorElement method is throwing an error. I wouldn't think this would cause that particular error (14791). But even if not, I would suspect that this will not work very well overall. I don't understand the point of having a custom version of this class that doesn't do anything - actually worse - it takes functionality away by basically disabling this method. But as I already said - I don't know how this class works, so if you know better, please let me know!
At the end the PropertyGridButtonEditor class will contain code to create a button. This button will appear in the ItemValueField of the propertyGrid at the moment the user clicks the item field and the field goes in edit mode.
At the moment we removed all the extra code from our class because we want to find out what is causing the error first.
Here is the stack trace:
Unfortunatly the Telerik propertyGrid has nothing build-in to add a button to a valueField, so we have to write our own class to make it possible.
Please see the Telerik documentation about this topic:
http://www.telerik.com/help/winforms/propertygrid-editors-using-custom-editor.html
If you know a better way to achieve the result we wanted, I am happy to hear it because we are stuck at the moment.
An instance of your custom class needs to exist at the time that the grid is displayed. And somehow the grid needs access to that instance. How is that happening? I presume you set it somewhere. But this error is simply saying that at the time the grid is trying to call the CreateEditorElement method there is no longer a valid instance of the class in the ABL to call. Remember that the ABL does garbage collection so if the class instance was created in a context that has gone out of scope, we will have garbage collected it.