473,320 Members | 1,804 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,320 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 1093

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jeff Molby | last post by:
Ok, I've googled long and hard, but I can't find anything relevant on this one. I am now at the mercy of your good nature. <g> I have 3 projects in my solution: One app and 2 libraries. I am...
9
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
6
by: Tamir Khason | last post by:
I have some classes that basicly do the same things but different way. There are no default constructors in those classes each constructor should recieve same value So Fooclass:MyBasicClass...
10
by: Chris Morse | last post by:
Hi, I'm trying to figure out how to dynamically load an assembly and get an IClientPlugin interface to a class. I can get an "Object" reference to it after doing an "Activator.CreateInstance"...
3
by: topdawg147 | last post by:
Is there any way to retrieve a list of objects that implement an interface. For example, suppose we have the following: Public Interface ISomething Function SomeFunction() As String End...
8
by: Bill Rust | last post by:
I've created an "Add Item" wizard for VB.NET 2003 that allows a user to add a specialized class that works with my application framework. In the wizard, the user can select the interfaces they...
20
by: Luc Kumps | last post by:
(Sorry about the previous post, it got transmitted before it was complete) We try to separate implementation and interface defintions, but we run into a problem. I hope the guru's can solve this,...
0
by: YellowFin Announcements | last post by:
Introduction Usability and relevance have been identified as the major factors preventing mass adoption of Business Intelligence applications. What we have today are traditional BI tools that...
8
by: rowe_newsgroups | last post by:
I know this has to be answered in the archives somewhere, but the search results are just confusing me more :-( Anyways, I authored a control library that contains an Interface definition and...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.