By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,911 Members | 1,170 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,911 IT Pros & Developers. It's quick & easy.

storing a DataGridView in a Setting

P: n/a
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.
Apr 13 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
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>)
Apr 14 '06 #2

P: n/a
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."

Apr 14 '06 #3

P: n/a
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>)
Apr 15 '06 #4

P: n/a
Actually, Ken, you can't store a DataGridView in the Settings file because
it isn't Serializable.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Ken Arway" <ka****@jaguar.att.net> wrote in message
news:et**************@TK2MSFTNGP02.phx.gbl...
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>)

Apr 15 '06 #5

P: n/a
Kevin Spencer wrote:
Actually, Ken, you can't store a DataGridView in the Settings file because
it isn't Serializable.

Yep, I learned that one the hard way.
--
Take care,
Ken
(to reply directly, remove the cool car. <sigh>)
Apr 16 '06 #6

P: n/a
Hi Ken,

This depends on how you display data on the DataGridView. Could you show us
some of your code that put data on the datagridView?

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

Apr 17 '06 #7

P: n/a
Kevin Yu [MSFT] wrote:
Hi Ken,

This depends on how you display data on the DataGridView. Could you show us
some of your code that put data on the datagridView?


Unfortunately, I no longer can show how I was populating the unbound DataGridView--now that I'm using a bound DataGridView, the current code shows how I'm populating it's underlying dataset and I don't have samples of the previous code.

--
Take care,
Ken
(to reply directly, remove the cool car. <sigh>)
Apr 18 '06 #8

P: n/a
So how do I connect the DataGridView to a DataSource after I have filled
the DataGridView?

On Thu, 13 Apr 2006 18:35:00 -0700, Ken Arway <ka****@jaguar.att.net>
wrote:
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.


Apr 18 '06 #9

P: n/a
michael sorens wrote:
So how do I connect the DataGridView to a DataSource after I have filled
the DataGridView?

On Thu, 13 Apr 2006 18:35:00 -0700, Ken Arway <ka****@jaguar.att.net>
wrote:
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.


I did all the work in the VS2005 IDE: I created a dataset from an XSD file (using XSD.exe), added it to the project and after compiling added it as a DataSource in VS2005. The appropriate BindingSource was automagically added and I simply dragged the DataGridView from the DataSource Explorer onto my form. After that, I wrote my code to populate the DataSet, not the DataGridView.

--
Take care,
Ken
(to reply directly, remove the cool car. <sigh>)
Apr 19 '06 #10

P: n/a
Hi,

Actually, you're not filling the DataGridView itself. You're filling the
DataSource. After you have filled it, just use DataGridView.DataSource =
dataset; to bind it. (Assume the data source is a dataset.)

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

Apr 19 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.