473,396 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 6421
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Abhi | last post by:
In the following hypothetical example I want to build a generic list of unique string items. How should I implement the pred function so that it returns true/false if target string exists in the...
5
by: majm | last post by:
I'm trying to implement strongly typed lists in the 2.0 framework. I'm using VS2005 beta 2. So far, System.Collections.Generic.List appears to be the ideal solution. However, the...
2
by: Nicolas Fleury | last post by:
Hi, I have a field named "BaseClasses" in C++ as in the following simplified code: using Collections::Generic::List; namespace A2M { namespace LipIntrospection { public ref class...
0
by: crazyone | last post by:
I've got a gaming framework i'm building and i want to save myself the trouble of reading and writting the complete game data to a custom file and load/save it to an XML file but i'm getting...
4
by: rsa_net_newbie | last post by:
Hi there, I have a Managed C++ object (in a DLL) which has a method that is defined like ... Generic::List<String^>^ buildList(String^ inParm) Now, when I compile it, I get "warning C4172:...
3
by: Peter Olcott | last post by:
How does not specify the sort criteria for Generic.List ?? The way that this is done in C++ STL is to implement operator<(), how is this done in C# and DotNet for Generic.List ???
8
by: Nip | last post by:
Hi I want to access the Generic List of the following c++-class inside a vb.net app. Is this possible/how can I do that? Atm, I get the following error in the vb.net app: "Field 'GeoElems' is of...
1
by: shapper | last post by:
Hello, I have an Enum and a Generic.List(Of Enum) 1 Public Enum Mode 2 Count 3 Day 4 Month 5 End Enum
3
by: Arcadefreaque | last post by:
I'm realizing how little I know about C++ today as I try to convert some functionality from VB.Net to C++. I have a procedure that I need to pass a List of objects to, and cannot see how to do...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.