473,911 Members | 6,170 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6447
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.co m

"Vivek" <vi****@xtra.co .nz> wrote in message
news:OY******** *****@TK2MSFTNG P09.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.c om> wrote in
message news:e2******** ******@TK2MSFTN GP14.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.co m

"Vivek" <vi****@xtra.co .nz> wrote in message
news:OY******** *****@TK2MSFTNG P09.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******** ********@TK2MSF TNGP15.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
15190
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 generic list...is not clear to me. Any suggestions? System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>(); foreach(string s in myAnotherArray)
5
5453
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 generic.List.IndexOf function doesn't appear to be invoking the contained class' CompareTo method. My understanding is that it should. The contained class (IssStruct) implements the IComparable and IComparable<T> interfaces. However, the List.Sort function...
2
5476
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 BaseClassInfo { ...
0
5936
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 problem serializing my stuff to XML when it comes to collections. I'm currently using .net2 with generic lists to prevent users putting all sorts of stuff in the arrays (Although im sure i'll be the only user of the classes but not the game, anyway)....
4
2964
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: returning address of local variable or temporary". In good old 'C', that would indicate that a 'static' was missing from the declaration of the returned value.
3
2282
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
2024
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 an unsupported type." public ref class clsPhysik {
1
1705
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
1506
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 this using C++. It's easy in VB.Net, so I'm hoping it is just my silly misunderstanding of c++ that is preventing me from doing this in c++. In VB.Net, to create a couple of objects and add them into a generic list, this is the code that is...
0
9879
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11349
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11055
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9727
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8099
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7250
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5939
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6142
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4337
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.