473,401 Members | 2,125 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,401 software developers and data experts.

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 4946
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.com

"Vivek" <vi****@xtra.co.nz> wrote in message
news:ub**************@TK2MSFTNGP12.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.com> wrote in
message news:e9**************@TK2MSFTNGP11.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.com

"Vivek" <vi****@xtra.co.nz> wrote in message
news:ub**************@TK2MSFTNGP12.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.com

"Vivek" <vi****@xtra.co.nz> wrote in message
news:uW**************@tk2msftngp13.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.com> wrote
in message news:e9**************@TK2MSFTNGP11.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.com

"Vivek" <vi****@xtra.co.nz> wrote in message
news:ub**************@TK2MSFTNGP12.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)

{

InitializeComponent();

_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.com> wrote in
message news:%2****************@TK2MSFTNGP12.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.com

"Vivek" <vi****@xtra.co.nz> wrote in message
news:uW**************@tk2msftngp13.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.com> wrote
in message news:e9**************@TK2MSFTNGP11.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.com

"Vivek" <vi****@xtra.co.nz> wrote in message
news:ub**************@TK2MSFTNGP12.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.com

"Vivek" <vi****@xtra.co.nz> wrote in message
news:ec*************@TK2MSFTNGP15.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)

{

InitializeComponent();

_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.com> wrote
in message news:%2****************@TK2MSFTNGP12.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.com

"Vivek" <vi****@xtra.co.nz> wrote in message
news:uW**************@tk2msftngp13.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.com> wrote
in message news:e9**************@TK2MSFTNGP11.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.com

"Vivek" <vi****@xtra.co.nz> wrote in message
news:ub**************@TK2MSFTNGP12.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.Collections.Generic.List<LPADMIN.Classes.R ole>' is less accessible
than method 'LPADMIN.Designer.RoleForm.RoleForm(int,
System.Collections.Generic.List<LPADMIN.Classes.Ro le>)' D:\Windows
Applications\Agoge\LPADMIN\LPADMIN\Designer\RoleFo rm.cs 17 16 LPADMIN
************************************************** ************************************************** *****

Can you please help?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:OX****************@tk2msftngp13.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.com

"Vivek" <vi****@xtra.co.nz> wrote in message
news:ec*************@TK2MSFTNGP15.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)

{

InitializeComponent();

_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.com> wrote
in message news:%2****************@TK2MSFTNGP12.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.com

"Vivek" <vi****@xtra.co.nz> wrote in message
news:uW**************@tk2msftngp13.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.com>
wrote in message news:e9**************@TK2MSFTNGP11.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.com
>
> "Vivek" <vi****@xtra.co.nz> wrote in message
> news:ub**************@TK2MSFTNGP12.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****************@TK2MSFTNGP09.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.Collections.Generic.List<LPADMIN.Classes.R ole>' is less accessible
than method 'LPADMIN.Designer.RoleForm.RoleForm(int,
System.Collections.Generic.List<LPADMIN.Classes.Ro le>)' D:\Windows
Applications\Agoge\LPADMIN\LPADMIN\Designer\RoleFo rm.cs 17 16 LPADMIN
************************************************** ************************************************** *****

Can you please help?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:OX****************@tk2msftngp13.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.com

"Vivek" <vi****@xtra.co.nz> wrote in message
news:ec*************@TK2MSFTNGP15.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)

{

InitializeComponent();

_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.com> wrote
in message news:%2****************@TK2MSFTNGP12.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.com

"Vivek" <vi****@xtra.co.nz> wrote in message
news:uW**************@tk2msftngp13.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.com>
> wrote in message news:e9**************@TK2MSFTNGP11.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.com
>>
>> "Vivek" <vi****@xtra.co.nz> wrote in message
>> news:ub**************@TK2MSFTNGP12.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
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...
4
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>....
1
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
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...
7
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...
44
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...
56
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...
45
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...
9
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...
4
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...
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...
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
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...
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
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,...
0
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...

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.