在设置中存储DataGridView [英] storing a DataGridView in a Setting

查看:72
本文介绍了在设置中存储DataGridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将未绑定的DataGridView组件存储到设置中?

我天真地尝试定义一个名为DGV的DataGridView的设置,然后

只需分配它:

Properties.Settings.Default.DGV = myDataGridView;

关闭程序后,user.config文件显示一个空值,所以

显然这不是这样做的方法。

解决方案

michael sorens写道:

是否可以存储未绑定的DataGridView组件进入
设置?我天真地尝试定义一个名为DGG的DataGridView设置,然后简单地分配它:
Properties.Settings.Default.DGV = myDataGridView;
关闭程序后,user.config文件显示一个空值,显然这不是这样做的方法。



我从来没有找到办法做到这一点 - 尝试了几十个方法。我终于放弃了,只是将DataGridView绑定到DataSource并序列化了底层DataSet。


-

小心,

Ken

(直接回复,移走酷车。< sigh>)





我不认为你可以将DataGridView存储到一个设置中,因为

DataGridView本身并不包含任何数据。数据存储在

底层DataSource中。因此,最好存储数据源

。 HTH。


Kevin Yu

=======

此帖子已提供按现状没有保证,并且不授予

权利。


Kevin Yu [MSFT]写道:
< blockquote class =post_quotes>我不认为你可以将DataGridView存储到一个设置中,因为DataGridView本身并不包含任何数据。数据存储在底层DataSource中。因此,最好存储数据源
。 HTH。




那么,未绑定的DataGridView的数据源是什么?具体来说,我有一个DataGridView显示从OpenFileDialog中选择的文件。其他方法使用这些文件名就好了,但似乎无法将这些名称序列化。


-

小心,

Ken

(直接回复,移除酷车。< sigh>)


Is it possible to store an unbound DataGridView component into a setting?
I naively tried defining a Setting that is a DataGridView called DGV, then
simply assigning it:
Properties.Settings.Default.DGV = myDataGridView;
After I closed the program, the user.config file shows an empty value, so
apparently that is not the way to do it.

解决方案

michael sorens wrote:

Is it possible to store an unbound DataGridView component into a
setting? I naively tried defining a Setting that is a DataGridView
called DGV, then simply assigning it:
Properties.Settings.Default.DGV = myDataGridView;
After I closed the program, the user.config file shows an empty value,
so apparently that is not the way to do it.


I never found a way to do it -- tried dozens of methods. I finally gave up and just bound the DataGridView to a DataSource and serialized the underlying DataSet.

--
Take care,
Ken
(to reply directly, remove the cool car. <sigh>)


Hi,

I don''t think you can store the DataGridView into a setting, because the
DataGridView itself doesn''t contain any data. The data is stored in the
underlying DataSource. So, it will be better to store the datasource
instead. HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Kevin Yu [MSFT] wrote:

I don''t think you can store the DataGridView into a setting, because the
DataGridView itself doesn''t contain any data. The data is stored in the
underlying DataSource. So, it will be better to store the datasource
instead. HTH.



So, what''s the datasource of an unbound DataGridView? Specifically, I had a DataGridView displaying the files selected from an OpenFileDialog. Those file names were used by other methods just fine, but there appeared to be no way to serialize those names.

--
Take care,
Ken
(to reply directly, remove the cool car. <sigh>)


这篇关于在设置中存储DataGridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆