471,317 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 software developers and data experts.

Interface / Reflection Question

I have an interface called IChannel that has a series of items including a
delcaration for a Panel. I have a class called Channel that implements
IChannel. I'm wanting to dynamically load each channel at runtime. So, i
have a CustomerChannel that inherits Channel and it is bound at runtime and
everything i want to do happen happens.

My constructor for CustomerChannel looks like this:
CustomerChannel() : base("Customer");

This works fine!! However, now i need to have each channel that is created
and loaded dynamically to "supply" a panel of controls so that it can be
"added" to the navigation bar at runtime. My question is this: How do I
"pass" or "assign" this panel so that the main application loads it.

IChannel looks like this:

string Name {get; set; }
Panel NavPanel {get; set; }

How do i get this Panel into my main application? I hope my question makes
sense.

Thanks in advance.
Doug
Dec 1 '05 #1
4 1051

Doug Handler wrote:
I have an interface called IChannel that has a series of items including a
delcaration for a Panel. I have a class called Channel that implements
IChannel. I'm wanting to dynamically load each channel at runtime. So, i
have a CustomerChannel that inherits Channel and it is bound at runtime and
everything i want to do happen happens.

My constructor for CustomerChannel looks like this:
CustomerChannel() : base("Customer");

This works fine!! However, now i need to have each channel that is created
and loaded dynamically to "supply" a panel of controls so that it can be
"added" to the navigation bar at runtime. My question is this: How do I
"pass" or "assign" this panel so that the main application loads it.

IChannel looks like this:

string Name {get; set; }
Panel NavPanel {get; set; }

How do i get this Panel into my main application? I hope my question makes
sense.


I don't think you need any reflection here (which is good, because it's
no fun). To give you an idea what to do, create a plain winforms app,
drop a Panel on the form, and look at the autogenerated code. That will
show you how to get a Panel onto your form, once you have one. And
getting a Panel from a Channel is easy:

CustomerChannel myChannel = new CustomerChannel();
Panel channelpanel = ((IChannel)myChannel).NavPanel;
// now stuff that puts channelpanel into the actual UI container

Simple as that?

--
Larry Lard
Replies to group please

Dec 1 '05 #2
Easy: just set the position and size of the panel (via its properties),
then add it to the Controls collection of your main form:

mainForm.Controls.Add(generatedPanel);

and it will appear after the method that does the Add completes.

Dec 1 '05 #3
Hi Doug,

Check out this article on Reflection, it might help you answer your
question.

Stefan
C# GURU
www.DotNETovation.com

*** Sent via Developersdex http://www.developersdex.com ***
Dec 3 '05 #4

Oops!

Forget to post the link for the article.

http://www.developersdex.com/gurus/articles/739.asp

Stefan

*** Sent via Developersdex http://www.developersdex.com ***
Dec 4 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Tamir Khason | last post: by
3 posts views Thread by topdawg147 | last post: by
reply views Thread by YellowFin Announcements | last post: by
8 posts views Thread by rowe_newsgroups | 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.