在 IronPython Studio Winforms 中添加 DataGridView 会得到一个“DataGridView”对象没有属性“BeginInit”
只需在 IronPython Studio 中添加 datagridview 即可触发 “DataGridView”对象没有属性“BeginInit””。有解决办法吗?
如果删除 self._DataGridView1.BeginInit() 和 self._DataGridView1.EndInit() 行,错误就会消失,但这不是解决该问题的方法
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题没有解决办法,而且很可能也没有解决办法,因为 IronPython Studio 不再受支持。 DataGridView.BeginInit 是显式实现的,IronPython Studio 基于 IronPython 1.1。您也许可以在导入 ISupportInitialize 后将其更改为“ISupportInitialize.BeginInit(self._DataGridView1)”来解决它,但我怀疑它能否在设计器的往返中幸存下来。
如果您想自己修复此问题,可以使用 IronPython Studio 的源代码,并且您可以尝试修改 winforms 设计器代码以注意到显式接口实现调用并发出此代码。这可能只是修复 IronPython 的 CodeDom 生成器。
但实际上我建议您转向 IronPython Tools 和 WPF。为 WinForms 设计器生成代码并不能很好地使用 IronPython,而 WPF 更适合。另一种计划是使用 C# 中的设计器生成 WinForm,并从 Python 中对其进行子类化。
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.