Adding a DataGridView in IronPython Studio Winforms gets a “'DataGridView' object has no attribute 'BeginInit'”

扶醉桌前 提交于 2020-01-05 09:14:03

问题


By just adding a datagridview in IronPython Studio it triggers a "DataGridView' object has no attribute 'BeginInit'". Is there a fix for this?

The errors are gone if the lines self._DataGridView1.BeginInit() and self._DataGridView1.EndInit() are deleted, but that's not what it should be done to fix that


回答1:


There's no fix for this and there's likely not to be one because IronPython Studio isn't supported anymore. DataGridView.BeginInit is implemented explicitly and IronPython Studio is based upon IronPython 1.1. You might be able to work around with it by changing that to "ISupportInitialize.BeginInit(self._DataGridView1)" after importing ISupportInitialize but I doubt it'll survive round tripping through the designer.

If you wanted to fix this yourself the source for IronPython Studio is available and you could try modifying the winforms designer code to notice the explicit interface implementation call and emit this code instead. That's likely just fixing IronPython's CodeDom generator.

But really I'd advise you to move to IronPython Tools and WPF. Generating code for the WinForms designer doesn't really work that well with IronPython and WPF is much more suitable. An alternate plan would be to generate the WinForm w/ the designer in C# and subclass it from Python.



来源:https://stackoverflow.com/questions/2976803/adding-a-datagridview-in-ironpython-studio-winforms-gets-a-datagridview-objec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!