471,325 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

global generic list

Hi,

I have created a list<t> for my form that displays data in a listview. I
wixh to edit the row with the help of another form and then update the
list<t>. How do I declare a global list that I can use on various forms.

Thanks
Dec 27 '05 #1
6 6270
Vivek,

You don't necessarily have to make the variable global in scope. You
could pass the list from one form to another through a property or method or
public field. However, if you really want, you can just declare the list as
static and public, and then any type will have access to that.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vivek" <vi****@xtra.co.nz> wrote in message
news:OY*************@TK2MSFTNGP09.phx.gbl...
Hi,

I have created a list<t> for my form that displays data in a listview. I
wixh to edit the row with the help of another form and then update the
list<t>. How do I declare a global list that I can use on various forms.

Thanks

Dec 27 '05 #2
Thanks. How can I update the LIST once I have updated the values? My target
is to update the database and the list at the same time and then reload my
listview control from LIST.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:e2**************@TK2MSFTNGP14.phx.gbl...
Vivek,

You don't necessarily have to make the variable global in scope. You
could pass the list from one form to another through a property or method
or public field. However, if you really want, you can just declare the
list as static and public, and then any type will have access to that.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vivek" <vi****@xtra.co.nz> wrote in message
news:OY*************@TK2MSFTNGP09.phx.gbl...
Hi,

I have created a list<t> for my form that displays data in a listview. I
wixh to edit the row with the help of another form and then update the
list<t>. How do I declare a global list that I can use on various forms.

Thanks


Dec 27 '05 #3
"Vivek" <vi****@xtra.co.nz> a écrit dans le message de news:
ep**************@TK2MSFTNGP12.phx.gbl...

| Thanks. How can I update the LIST once I have updated the values? My
target
| is to update the database and the list at the same time and then reload my
| listview control from LIST.

If you want to allow full interaction with a list from controls like
DataGridView, etc, then you should create your own generic list class that
implements a couple of interfaces :

GenericList<T> : IList<T>, IBindingList, ICancelAddNew
{
private IList<T> items = new List<T>;

...
}

In implementing this class you can then talk to the database from inside
this list class, intercepting the calls that would normally go straight to a
List<T> and adding your own code to keep the database in sync.

Because of the interfaces implemented, data-aware list controls should
update themselves automatically.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Dec 27 '05 #4
Nicholas, Joanna...

Sometimes I think you guys are so helpful that I feel cynic and bitter when
I implement ICompare and foreach you.

Nicholas - Stop spending time on these kind of clueless posts and help where
the action is...You know too much about everything and should focus on the
hard problems. ... which you do great!

Joanna - Rewrite everything you ever written for DM, and your book, to C#
2.0; then ping MSDN Magazine and get yourself a column.. I sure would read
it...

Cheers
- Michael S

Dec 29 '05 #5
"Michael S" <no@mail.com> a écrit dans le message de news:
%2***************@TK2MSFTNGP10.phx.gbl...

| Joanna - Rewrite everything you ever written for DM, and your book, to C#
| 2.0; then ping MSDN Magazine and get yourself a column.. I sure would read
| it...

What is the best way to get in touch with MSDN Magazine ?

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Dec 29 '05 #6
"Joanna Carter [TeamB]" <jo****@not.for.spam> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
"Michael S" <no@mail.com> a écrit dans le message de news:
%2***************@TK2MSFTNGP10.phx.gbl...

| Joanna - Rewrite everything you ever written for DM, and your book, to
C#
| 2.0; then ping MSDN Magazine and get yourself a column.. I sure would
read
| it...

What is the best way to get in touch with MSDN Magazine ?

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer


Well, you have several options.

If you want to go hightech you could always use a phone. Or email. If that
is way too complex for you, there is this ROM device called a pencil. It
typically sports fethers and you do it with ink. And there is this device
made out of carbon and parts of a tree, that is actually a kinda RAM. It has
this rubber thingy on that back that makes for rewrites....

As for the editor of MSDN... I have no idea. But I think he (or she) would
be happy if he (or she) got a message saying - I'm freek'n Joanna Carter,
now let me type and then you send me alot of money!

Good luck
- Michael S
Dec 30 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Nicolas Fleury | last post: by
reply views Thread by crazyone | last post: by
3 posts views Thread by Peter Olcott | last post: by
1 post views Thread by shapper | last post: by
3 posts views Thread by Arcadefreaque | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.