471,312 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,312 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 4831
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Dave | last post: by
1 post views Thread by Diego | last post: by
reply views Thread by Iron Moped | last post: by
7 posts views Thread by Andrew Robinson | last post: by
44 posts views Thread by Zytan | last post: by
9 posts views Thread by =?Utf-8?B?VHJlY2l1cw==?= | 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.