Search code examples
python.netpropertygrid

Creating and Populating a Porperty Grid - Iron Python


I am creating an Iron Python application that reads settings from an xml. It will also allow the user to saves out settings to an xml file.

I have to use Iron Python. I looked and tried to use the DataGridView to accomplish this, but I think the Property Grid is my best option (please let me know if there is a better way to create a simple settings table).

I added the property grid to the form, and now I do not know how to add the data to it. I tried using this example: http://msdn.microsoft.com/en-us/library/aa302326.aspx

However, that is in C#. I am not sure what I am doing wrong:

class MainForm(Form):
    def __init__(self):
        self.InitializeComponent()
        appset = AppSettings();
        self._propertyGrid1.SelectedObject = appset

    def InitializeComponent(self):
        self._propertyGrid1 = System.Windows.Forms.PropertyGrid()

class AppSettings(self):
    def __init__(self):
        saveOnClose = True
    def saveOnClose(self):
        return self.saveOnClose

Solution

  • Realized I was doing something dumb.

    class MainForm(Form):
        def __init__(self):
            self.InitializeComponent()
            appset = AppSettings();
            self._propertyGrid1.SelectedObject = appset
    
        def InitializeComponent(self):
            self._propertyGrid1 = System.Windows.Forms.PropertyGrid()
    
    class AppSettings():
        def __init__(self):
            self.saveOnClose = True
        def saveOnClose(self):
            return self.saveOnClose