473,725 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Update LIST<T> from a different form

Hi,

I wish to update the LIST<T> created in PARENT FORM from the CHILD FORM.
Currently I have declared the LIST<Role> as public in my parent form. What
can I do to update the <LIST>?

Thanks
Dec 27 '05 #1
8 4961
Vivek,

Why not pass the List<T> to the child form when you create it from the
parent? You can pass it through a constructor, through a property, public
field, or method.

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

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

I wish to update the LIST<T> created in PARENT FORM from the CHILD FORM.
Currently I have declared the LIST<Role> as public in my parent form.
What can I do to update the <LIST>?

Thanks

Dec 27 '05 #2
It sure did. I'll have to find out how to pass the list to the child form.
can you please mention if you know an efficient way.

Thanks
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:e9******** ******@TK2MSFTN GP11.phx.gbl...
Vivek,

Why not pass the List<T> to the child form when you create it from the
parent? You can pass it through a constructor, through a property, public
field, or method.

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

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

I wish to update the LIST<T> created in PARENT FORM from the CHILD FORM.
Currently I have declared the LIST<Role> as public in my parent form.
What can I do to update the <LIST>?

Thanks


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

| I wish to update the LIST<T> created in PARENT FORM from the CHILD FORM.
| Currently I have declared the LIST<Role> as public in my parent form.
What
| can I do to update the <LIST>?

I already answered this, here is my reply from the other thread :

////////////////////////////
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
Vivek,

Again, why not just call a method on the child form, passing the list to
it? It's like passing a parameter to any other method.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Vivek" <vi****@xtra.co .nz> wrote in message
news:uW******** ******@tk2msftn gp13.phx.gbl...
It sure did. I'll have to find out how to pass the list to the child
form. can you please mention if you know an efficient way.

Thanks
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote
in message news:e9******** ******@TK2MSFTN GP11.phx.gbl...
Vivek,

Why not pass the List<T> to the child form when you create it from the
parent? You can pass it through a constructor, through a property,
public field, or method.

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

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

I wish to update the LIST<T> created in PARENT FORM from the CHILD FORM.
Currently I have declared the LIST<Role> as public in my parent form.
What can I do to update the <LIST>?

Thanks



Dec 27 '05 #5
I have a class ROLE with all the properties declared. I am adding the roles
to the list
I tried this and gave me an error
*************** *************** *************** ********
public RoleForm(int RoleID, List<T> lRole)

{

InitializeCompo nent();

_ID = RoleID;

}

*************** *************** *************** *************** **

ERROR:Error 1 The type or namespace name 'T' could not be found (are you
missing a using directive or an assembly reference?)

*************** *************** *************** ********

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Vivek,

Again, why not just call a method on the child form, passing the list
to it? It's like passing a parameter to any other method.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Vivek" <vi****@xtra.co .nz> wrote in message
news:uW******** ******@tk2msftn gp13.phx.gbl...
It sure did. I'll have to find out how to pass the list to the child
form. can you please mention if you know an efficient way.

Thanks
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote
in message news:e9******** ******@TK2MSFTN GP11.phx.gbl...
Vivek,

Why not pass the List<T> to the child form when you create it from
the parent? You can pass it through a constructor, through a property,
public field, or method.

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

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

I wish to update the LIST<T> created in PARENT FORM from the CHILD
FORM. Currently I have declared the LIST<Role> as public in my parent
form. What can I do to update the <LIST>?

Thanks



Dec 27 '05 #6
Vivek,

Unless your class is Generic, you want to do this:

public RoleForm(int RoleId, List<Role> lRole)

By the way, you should not name your parameter lRole, but rather, Roles.
The public naming guidelines indicate that you should do something else.

The reason what I typed works is because when you say List<T>, if T
isn't a type parameter, then the compiler will look for a type named T. You
need to set the specific type for the generic parameter.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Vivek" <vi****@xtra.co .nz> wrote in message
news:ec******** *****@TK2MSFTNG P15.phx.gbl...
I have a class ROLE with all the properties declared. I am adding the roles
to the list
I tried this and gave me an error
*************** *************** *************** ********
public RoleForm(int RoleID, List<T> lRole)

{

InitializeCompo nent();

_ID = RoleID;

}

*************** *************** *************** *************** **

ERROR:Error 1 The type or namespace name 'T' could not be found (are you
missing a using directive or an assembly reference?)

*************** *************** *************** ********

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote
in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Vivek,

Again, why not just call a method on the child form, passing the list
to it? It's like passing a parameter to any other method.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Vivek" <vi****@xtra.co .nz> wrote in message
news:uW******** ******@tk2msftn gp13.phx.gbl...
It sure did. I'll have to find out how to pass the list to the child
form. can you please mention if you know an efficient way.

Thanks
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote
in message news:e9******** ******@TK2MSFTN GP11.phx.gbl...
Vivek,

Why not pass the List<T> to the child form when you create it from
the parent? You can pass it through a constructor, through a property,
public field, or method.

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

"Vivek" <vi****@xtra.co .nz> wrote in message
news:ub******** ******@TK2MSFTN GP12.phx.gbl...
> Hi,
>
> I wish to update the LIST<T> created in PARENT FORM from the CHILD
> FORM. Currently I have declared the LIST<Role> as public in my parent
> form. What can I do to update the <LIST>?
>
> Thanks
>



Dec 27 '05 #7
Nicholas, Thanks for your help. I tried renaimg from <T> to <Role> and it
gives me an error

*************** *************** *************** *********
Error 1 Inconsistent accessibility: parameter type
'System.Collect ions.Generic.Li st<LPADMIN.Clas ses.Role>' is less accessible
than method 'LPADMIN.Design er.RoleForm.Rol eForm(int,
System.Collecti ons.Generic.Lis t<LPADMIN.Class es.Role>)' D:\Windows
Applications\Ag oge\LPADMIN\LPA DMIN\Designer\R oleForm.cs 17 16 LPADMIN
*************** *************** *************** *************** *************** *************** ***************

Can you please help?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:OX******** ********@tk2msf tngp13.phx.gbl. ..
Vivek,

Unless your class is Generic, you want to do this:

public RoleForm(int RoleId, List<Role> lRole)

By the way, you should not name your parameter lRole, but rather,
Roles. The public naming guidelines indicate that you should do something
else.

The reason what I typed works is because when you say List<T>, if T
isn't a type parameter, then the compiler will look for a type named T.
You need to set the specific type for the generic parameter.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Vivek" <vi****@xtra.co .nz> wrote in message
news:ec******** *****@TK2MSFTNG P15.phx.gbl...
I have a class ROLE with all the properties declared. I am adding the
roles to the list
I tried this and gave me an error
*************** *************** *************** ********
public RoleForm(int RoleID, List<T> lRole)

{

InitializeCompo nent();

_ID = RoleID;

}

*************** *************** *************** *************** **

ERROR:Error 1 The type or namespace name 'T' could not be found (are you
missing a using directive or an assembly reference?)

*************** *************** *************** ********

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote
in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Vivek,

Again, why not just call a method on the child form, passing the list
to it? It's like passing a parameter to any other method.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Vivek" <vi****@xtra.co .nz> wrote in message
news:uW******** ******@tk2msftn gp13.phx.gbl...
It sure did. I'll have to find out how to pass the list to the child
form. can you please mention if you know an efficient way.

Thanks
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om>
wrote in message news:e9******** ******@TK2MSFTN GP11.phx.gbl...
> Vivek,
>
> Why not pass the List<T> to the child form when you create it from
> the parent? You can pass it through a constructor, through a
> property, public field, or method.
>
> Hope this helps.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mv*@spam.guard. caspershouse.co m
>
> "Vivek" <vi****@xtra.co .nz> wrote in message
> news:ub******** ******@TK2MSFTN GP12.phx.gbl...
>> Hi,
>>
>> I wish to update the LIST<T> created in PARENT FORM from the CHILD
>> FORM. Currently I have declared the LIST<Role> as public in my parent
>> form. What can I do to update the <LIST>?
>>
>> Thanks
>>
>
>



Dec 27 '05 #8
I think I have figured out what is wrong
"Vivek" <vi****@xtra.co .nz> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Nicholas, Thanks for your help. I tried renaimg from <T> to <Role> and it
gives me an error

*************** *************** *************** *********
Error 1 Inconsistent accessibility: parameter type
'System.Collect ions.Generic.Li st<LPADMIN.Clas ses.Role>' is less accessible
than method 'LPADMIN.Design er.RoleForm.Rol eForm(int,
System.Collecti ons.Generic.Lis t<LPADMIN.Class es.Role>)' D:\Windows
Applications\Ag oge\LPADMIN\LPA DMIN\Designer\R oleForm.cs 17 16 LPADMIN
*************** *************** *************** *************** *************** *************** ***************

Can you please help?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote
in message news:OX******** ********@tk2msf tngp13.phx.gbl. ..
Vivek,

Unless your class is Generic, you want to do this:

public RoleForm(int RoleId, List<Role> lRole)

By the way, you should not name your parameter lRole, but rather,
Roles. The public naming guidelines indicate that you should do something
else.

The reason what I typed works is because when you say List<T>, if T
isn't a type parameter, then the compiler will look for a type named T.
You need to set the specific type for the generic parameter.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Vivek" <vi****@xtra.co .nz> wrote in message
news:ec******** *****@TK2MSFTNG P15.phx.gbl...
I have a class ROLE with all the properties declared. I am adding the
roles to the list
I tried this and gave me an error
*************** *************** *************** ********
public RoleForm(int RoleID, List<T> lRole)

{

InitializeCompo nent();

_ID = RoleID;

}

*************** *************** *************** *************** **

ERROR:Error 1 The type or namespace name 'T' could not be found (are you
missing a using directive or an assembly reference?)

*************** *************** *************** ********

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote
in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Vivek,

Again, why not just call a method on the child form, passing the
list to it? It's like passing a parameter to any other method.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Vivek" <vi****@xtra.co .nz> wrote in message
news:uW******** ******@tk2msftn gp13.phx.gbl...
> It sure did. I'll have to find out how to pass the list to the child
> form. can you please mention if you know an efficient way.
>
> Thanks
>
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om>
> wrote in message news:e9******** ******@TK2MSFTN GP11.phx.gbl...
>> Vivek,
>>
>> Why not pass the List<T> to the child form when you create it from
>> the parent? You can pass it through a constructor, through a
>> property, public field, or method.
>>
>> Hope this helps.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard. caspershouse.co m
>>
>> "Vivek" <vi****@xtra.co .nz> wrote in message
>> news:ub******** ******@TK2MSFTN GP12.phx.gbl...
>>> Hi,
>>>
>>> I wish to update the LIST<T> created in PARENT FORM from the CHILD
>>> FORM. Currently I have declared the LIST<Role> as public in my
>>> parent form. What can I do to update the <LIST>?
>>>
>>> Thanks
>>>
>>
>>
>
>



Dec 27 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
5626
by: Dave | last post by:
Hello all, After perusing the Standard, I believe it is true to say that once you insert an element into a std::list<>, its location in memory never changes. This makes a std::list<> ideal for storing vertices of an arbitrary n-ary tree where a vertex contain pointers to its parent / children. These parent / child vertices need to stay put if we've got pointers to them somewhere! Am I correct in my assertion?
4
52987
by: matty.hall | last post by:
I have two classes: a base class (BaseClass) and a class deriving from it (DerivedClass). I have a List<DerivedClass> that for various reasons needs to be of that type, and not a List<BaseClass>. However, I need to cast that list to a List<BaseClass> and it is not working. The code is below. I get the following exception: "Unable to cast object of type 'System.Collections.Generic.List`1' to type 'System.Collections.Generic.List`1'." ...
1
6033
by: Diego | last post by:
I need to display a list of ojects (containing few fields like name, surname, adress) in a Grid, is it possible to directly bind the list of objects with the DataGridView? Thanks, Diego
0
1750
by: Iron Moped | last post by:
I'm airing frustration here, but why does LinkedList<not support the same sort and search methods as List<>? I want a container that does not support random access, allows forward and reverse traversal and natively supports sorting, i.e., STL's list<T>. There isn't even a set of algorithms that would allow me to easily sort a generic collection. System.Array has a robust set of static algorithms, why not extend this to ICollection?
7
57554
by: Andrew Robinson | last post by:
I have a method that needs to return either a Dictionary<k,vor a List<v> depending on input parameters and options to the method. 1. Is there any way to convert from a dictionary to a list without itterating through the entire collection and building up a list? 2. is there a common base class, collection or interface that can contain either/both of these collection types and then how do you convert or cast from the base to either a...
44
39178
by: Zytan | last post by:
The docs for List say "The List class is the generic equivalent of the ArrayList class." Since List<is strongly typed, and ArrayList has no type (is that called weakly typed?), I would assume List<is far better. So, why do people use ArrayList so often? Am I missing somehing? What's the difference between them? Zytan
56
5193
by: Zytan | last post by:
Obviously you can't just use a simple for loop, since you may skip over elements. You could modify the loop counter each time an element is deleted. But, the loop ending condition must be checked on each iteration, since the Count changes as you delete elements. I would think it is guaranteed to be computed each time, and not cached. So, is this the best way?
45
18883
by: Zytan | last post by:
This returns the following error: "Cannot modify the return value of 'System.Collections.Generic.List<MyStruct>.this' because it is not a variable" and I have no idea why! Do lists return copies of their elements? Why can't I change the element itself? class Program { private struct MyStruct
9
6182
by: =?Utf-8?B?VHJlY2l1cw==?= | last post by:
Hello, Newsgroupians: I've an optimization question for you all really quick. I have a stream that I am reading some bytes. At times, the stream can contain a small amount of bytes such as 50 or so or it can contain as much 10000000 bytes. In reality, I do not know the maximum number of bytes. In my function, I am going to read() the byte stream using a buffer. Now, is it better to read it into a buffer and dump the buffer into a...
4
8928
by: =?Utf-8?B?SkI=?= | last post by:
Hello List<Tis said to be more powerful than ArrayLists but if you have something like this: List<intmylst = new List<>; myList.Add("Joe"); myList.Add(25); the list doesn't seem to accept the name "Joe".
0
8886
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8750
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
9401
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...
0
9256
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9168
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
8091
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
3218
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2154
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.