VC2008, 一个基于MFC的对话框程序,用CWinFormsControl在这个对话框中使用一些.net的控件。 大部分都没有问题,但用到datagridview的时候, 一切都成功,编译,运行,但就是无法显示出绑定好的数据。 datagridview上一片空白。
于是google了一下类似情况,只有很少的信息,找到一个帖子很相似 http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic47311.aspx
帖子中说到的解决方案是
This is failing because data-binding requires that the bound control have
a BindingContext. Normally the DataGridView would use the BindingContext
belonging to the Form it is on, but since the test applicationâ??s DataGridView
is on an MFC dialog rather than on a Form it cannot use its parentâ??s context.
To use data-binding with the MFC-hosted DataGridView will require that the
application either create and manage the BindingContext on its own or host
the DataGridView inside a ContainerControl (such as a UserControl) which will
manage a binding context for its children.
能否有人能指导一下,如何create and manage the BindingContext on its own 或者如何 host
the DataGridView inside a ContainerControl (such as a UserControl) which will
manage a binding context for its children.
刚刚开始学习.net,困扰好久了。 拜托各位指点一下。 非常感谢!!
------解决方案--------------------------------------------------------
就是做一个.net的控件,把datagridview嵌入到里面,在mfc下用这个.net控件代替直接用datagridview。