Firstly - congratulations on a great control!
However, I've stumbled across a potential deal breaker. :(
I have some quite complex data structures that I need to work with. My prototype was written in vb + winforms, but my production app is in wpf mvvm. It basically allows you to set up game controls for games. Below is an example of it in action - you'll see it opens a custom modal window (that I designed) which returns a List(of T) where T is another class (quite complex data structures - thus the need for custom collection editor windows). The PropertyGrid's built-in Collection Editor functionality is not going to be sufficient in itself to do what I need. The video of it in action:
So here are the relevant bits of the data classes:
Public Class Game
Public Property GameControlFunctions As New List(Of GameControlFunction)
End Class
Public Class GameControlFunction
Public Property ID As ObjectId = ObjectId.NewObjectId
Public Property Control As stig.Control
Public Property GameMode As GameMode
Public Property GameFunction As String = Nothing
End Class
And here is the associated UITypeEditor Class and Form:
Public Class GameControlFunctionsUIEditor
Inherits UITypeEditor
Public Overrides Function GetEditStyle(ByVal context As ITypeDescriptorContext) As UITypeEditorEditStyle
If context Is Nothing OrElse context.Instance Is Nothing Then Return MyBase.GetEditStyle(context)
Return UITypeEditorEditStyle.Modal
End Function
Public Overrides Function EditValue(ByVal context As ITypeDescriptorContext, ByVal provider As IServiceProvider,
ByVal value As Object) As Object
Dim editorService As IWindowsFormsEditorService
If context Is Nothing OrElse context.Instance Is Nothing OrElse provider Is Nothing Then Return value
editorService = CType(provider.GetService(GetType(IWindowsFormsEditorService)), IWindowsFormsEditorService)
Dim game As Game = DirectCast(context.Instance, Game)
Dim editorForm As New GameControlFunctionsForm(value, game)
If editorService.ShowDialog(editorForm) = Windows.Forms.DialogResult.OK Then
Return New List(Of GameControlFunction)(editorForm.GameControlFunctionsList)
End If
Return value
End Function
End Class
Public Class GameControlFunctionsForm
' This holds the GameControlFunctions List that ultimately updates the GameCOntrolFunctions in Game
Public GameControlFunctionsList As New List(Of GameControlFunction)
' All Other Form logic code here
End Class
I really would like to use this control, but really do need to be able to use custom collection editors. Is this possible at all?
Hi Steve,
Sorry for the delay in getting back to you.
Regards,
Gokul T.
Hi Gokul,
The video is on youtube and is publicly available, so I don't understand why you can't see it. I have just tested it and it works just fine for me without being logged into youtube.
On (1) - I'm not sure what code you are asking for as I am asking about how you would hypothetically achieve something in this control based on the prototype I am showing in the video which used WinForm PropertyGrid. My prototype is not easy to share, unfortunately as it is not a stand alone application but dependant upon other 3rd party applications that I cannot distribute.
thanks
Steve
Hi Steve,
Regards,
Gokul T.
Hi Gokul. Glad you could view the video. If it's a region lock thing - couldn't you VPN on a desktop to access youtube?
As per my original post - the video is showing you an example of what functionality I am trying to achieve with SfPropertyGrid. The example is made with the standard Winforms PropertyGrid control and code included in the original post.
What I am asking is how I achieve similar with SfPropertyGrid. The Clooection Editor functions of SfPropertyGrid can't achieve this. I need the ability to launch custom modal windows and return values to the property as per my example.
Hope this makes sense and you can help
If it's still hard to understand, I can knock together a small VS Solution to show you what this would look like as a winforms project with the question "how would you achieve the same with WPF sfPropertyGrid?"
Hi Steve,
We have prepared the sample based on your requirement using a custom Editor. Please refer to the attached sample and video for your reference.
If we misunderstood your query, please provide more information about your query. So that we can prompt a better solution.
Regards,
Bagavathi Perumal A
Hi - thanks for this - I've had a quick look as a bit pushed for time at the moment and very busy this weekend. This is a good start and provides a good framework for making this work, although I note it doesn't pass the data objects (List<Author>) from the modal window back to the PropertyGrid Object Property (i.e Employee.CustomCollection).
However - it does give me something to work on. I'm, guessing Employee.CustomCollection should really be
Public Property CustomCollection As List(Of Author) = New List(Of Author)
As I say, I super busy this weekend, but will take a look when I can find some time with work on top, unless you know how to easily modify your code to achieve the data property update. Thanks for giving me a start, though
Hi Steve,
Regards,
Gokul T.
Gokul - you're an absolute ⭐
Thanks, man!
This is awesome.
Hi Steve,
We are glad to know that your issue has been fixed. Please let us know if you need any other assistance. We are happy to assist you.
Regards,
Gokul T.