Author Topic: PropertyGrid Overrides - ColorComboBox  (Read 1566 times)

0 Members and 1 Guest are viewing this topic.

rugaroo

  • Bull Frog
  • Posts: 378
  • The Other CAD Guy
PropertyGrid Overrides - ColorComboBox
« on: December 22, 2017, 02:02:03 AM »
Ok, so I am working with a PropertyGrid on a new project, and talk about a pain at first, but now I'm kind of loving it as long as I can get it to do what I need. Right now I am looking to see if anyone knows of a way to override a cell to be either a ColorComboBox like the typical properties palette.

So, for example, to override to a dropdown of layer names I have:

Code: [Select]
Public Class _LayerList : Inherits StringConverter
    Public Shared _LyrArray As String()

    Public Overloads Overrides Function GetStandardValues(ByVal context As ITypeDescriptorContext) As TypeConverter.StandardValuesCollection
        Return New StandardValuesCollection(_LyrArray)
    End Function

    Public Overloads Overrides Function GetStandardValuesSupported(ByVal context As ITypeDescriptorContext) As Boolean
        Return True
    End Function

    Public Overloads Overrides Function GetStandardValuesExclusive(ByVal context As ITypeDescriptorContext) As Boolean
        Return True
    End Function
End Class

Any ideas or examples on where I could start?

Thanks in advance!
LDD06-09 | C3D 04-19 | Infraworks 360 | VS2012-VS2017

MickD

  • King Gator
  • Posts: 3649
  • (x-in)->[process]->(y-out) ... simples!
Re: PropertyGrid Overrides - ColorComboBox
« Reply #1 on: December 22, 2017, 03:54:10 AM »
I worked with these years ago now so I don't have any code to hand but you will need to create your own TypeConverter (Like the StringConverter you are using) to populate the property field for editing. The 'field' can hold any control you want so you might need to create a custom control (or use the AutoCAD controls) and wire the TypeConverter to it.

I'll see if I can dig something up tomorrow but basically you need to inherit and then override the TypeConverter methods yourself.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien