[IronPython] IronPython objects as DataSource for DataGridView

C L realn2s at googlemail.com
Thu Jul 19 02:00:57 CEST 2007


Hello,

I try to use a DataGridView with a collection of IronPython objects.
The intention is to use the DataSource  property of the DataGridView
and let the columns be automatically defined.

Something like:
----
class MyDataObject :
    def __init__(self, a, b, c):
        # ...
        pass

f = Form( Name="Test")
dataGrid = DataGridView()

data = [ MyDataObject( 11, 12, 13 ) ]
# or
#data = [ [11, 12, 13 ] ]
dataGrid.DataSource = data
f.Controls.Add(dataGrid)
Application.Run(f)
----
This gives an exception (see below)

And I can't figure out which methods the objects or the container need to
provide
to get the column names.

 Do I have to "implement" IListSource for the container?

Any help appreciated

Regards,
Claudius

The exception I get is:

>From  System.MissingMemberException: 'instance' object has no attribute
'Get'
   at IronPython.Runtime.Operations.PythonOps.GetBoundAttr(CodeContext
context, Object o, SymbolId name)
   at
IronPython.Runtime.Operations.CustomTypeDescHelpers.SuperDynamicObjectPropertyDescriptor.GetValue(Object
component)
   at System.Windows.Forms.DataGridView.DataGridViewDataConnection.GetValue(Int32
boundColumnIndex, Int32 columnIndex, Int32 rowIndex)
>From  System.MissingMemberException: 'instance' object has no attribute
'Set'
   at IronPython.Runtime.Operations.PythonOps.GetBoundAttr(CodeContext
context, Object o, SymbolId name)
   at
IronPython.Runtime.Operations.CustomTypeDescHelpers.SuperDynamicObjectPropertyDescriptor.GetValue(Object
component)
   at System.Windows.Forms.DataGridView.DataGridViewDataConnection.GetValue(Int32
boundColumnIndex, Int32 columnIndex, Int32 rowIndex)
>From  System.MissingMemberException: 'instance' object has no attribute
'Address'
   at IronPython.Runtime.Operations.PythonOps.GetBoundAttr(CodeContext
context, Object o, SymbolId name)
   at
IronPython.Runtime.Operations.CustomTypeDescHelpers.SuperDynamicObjectPropertyDescriptor.GetValue(Object
component)
   at System.Windows.Forms.DataGridView.DataGridViewDataConnection.GetValue(Int32
boundColumnIndex, Int32 columnIndex, Int32 rowIndex)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20070719/3f0534b5/attachment.html>


More information about the Ironpython-users mailing list