.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 13th, 2004, 03:40 PM
MeestaCosgrove MeestaCosgrove is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 2 MeestaCosgrove User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Red face Calling User Controls by name

I read the thread about how to call another form just by name, but im having problems implementing that into my own solution.

I have a separate User Control library, but the main project has something like an option dialog. Im building the options through an XML tree, thus a treeview. What im trying to do is have the user click on a node in the tree, and the user control associated with it will be created and displayed on the screen.

The issue is that im making room so if we want to add different controls to the page without having to recompile the software, like a plug-in thingie. Any suggestions??

BTW, i keep getting nothing back when i run a step debug through the ObjectFinder function:

Imports System.Windows
Imports System.Windows.Forms
Imports System.Reflection

Public Class ObjectFinder
Public Shared Function CreateObjectInstance(ByVal objectName As String) As Object
Dim obj As Object
Try
If objectName.LastIndexOf(".") = -1 Then
'Appends the root namespace if not specified.
objectName = [Assembly].GetEntryAssembly.GetName.Name & "." & objectName
End If
obj = [Assembly].GetEntryAssembly.CreateInstance(objectName)

Catch ex As Exception
obj = Nothing
End Try
Return obj

End Function

Public Shared Function CreateForm(ByVal formName As String) As Form
' Return the instance of the form by specifying its name.
Return DirectCast(CreateObjectInstance(formName), Form)
End Function

' I added this one
Public Shared Function CreateControl(ByVal controlName As String) As UserControl
Return DirectCast(CreateObjectInstance(controlName), UserControl)
End Function

End Class

Reply With Quote
  #2  
Old December 14th, 2004, 10:04 AM
MeestaCosgrove MeestaCosgrove is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 2 MeestaCosgrove User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Found the cause

I found out what the error is. It seems that when im using the GetEntryAssembly, im getting the Assembly from the executing program. However, when i use GetExecutingAssembly, I get it from the code where the function exists, mainly the dll that i am using.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Calling User Controls by name


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT