![]() |
Click here to advertise with us
|
|
|||||||
| VB.NET General Discussion VB.NET general discussion area |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
I am using a PropertyGrid control. There are two things I need to be able to do.
1. I need to be able to access Ajax controltoolkit components and populate the propertygrid with the properties from the Ajax control toolkit. 2. I need to be able to do the same with WebUI components. The basic part, populating the propertygrid with a control, I understand how to do - - What I don't know is what to import or how to access what dll (for the Ajax Control Toolkit and the Web UI controls), in my Winforms project to be able to do this. Can anyone give me a little help here, please? |
|
||||
|
You can't use web controls in winforms projects.
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
|
|||
|
I don't really want to use them in the project itself - I just want to access the dlls and get the properties - -
Technically VS.Net does it, so there must be some way, I would think |
|
||||
|
I see, you have to use the 'Add Reference' dialog to add the assembly that has the class you want, documentation for the standard web controls say they are in assembly System.Web. For example for the TextBox class you can see this:
Quote:
Code:
Me.PropertyGrid1.SelectedObject = New System.Web.UI.WebControls.TextBox
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
|
|||
|
Theoretically, anyone using this application will have the DotNet platform on his/her computer.
So, once I've done this - if I compile and package the application - but the AjaxControlToolkit is not installed with DotNet - - Will the end user need to have this dll installed somewhere on his/her computer, or should my reference (and therefore, dll in the Bin and in the installed local app) in the project be enough to be able for the user to use the application? |
|
||||
|
If you reference a assembly your app becomes dependent of it, it must be present in order for your app to run. In deployment scenario it must then be included in setup for local libraries ('copy local' setting), or as a prerequisite (something that must be installed first) for external libraries such as the .Net Framework and the AjaxControlToolkit where these libraries are installed to GAC.
It is also possible to use libraries without referencing them at design time, by loading them dynamically at runtime using Reflection. You can then not write any strongly typed code for these libraries, only discover them with the Reflection type system. The most basic example is this, same as the Textbox example only now System.Web assembly is not referenced: Code:
Dim asm As Reflection.Assembly = Reflection.Assembly.Load("System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
Dim o As Object = asm.CreateInstance("System.Web.UI.WebControls.TextBox")
Me.PropertyGrid1.SelectedObject = o
Code:
Private Sub LoadWebControls()
Dim asm As Reflection.Assembly = Reflection.Assembly.Load("System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
Dim webControlType As Type = asm.GetType("System.Web.UI.WebControls.WebControl")
Dim controlTypes As New List(Of Type)
For Each t As Type In asm.GetExportedTypes
If webControlType.IsAssignableFrom(t) AndAlso t.Namespace = "System.Web.UI.WebControls" Then
Dim flags As Reflection.BindingFlags = Reflection.BindingFlags.Instance Or Reflection.BindingFlags.Public
Dim ctor As Reflection.ConstructorInfo = t.GetConstructor(flags, Nothing, Type.EmptyTypes, Nothing)
If ctor IsNot Nothing Then
controlTypes.Add(t)
End If
End If
Next
Me.ListBox1.DataSource = controlTypes
Me.ListBox1.DisplayMember = "Name"
End Sub
Code:
Private Sub ListBox1_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedValueChanged
Dim o As Object = Me.PropertyGrid1.SelectedObject
If o IsNot Nothing Then
CType(o, IDisposable).Dispose()
End If
Dim t As Type = CType(Me.ListBox1.SelectedValue, Type)
o = Activator.CreateInstance(t)
Me.PropertyGrid1.SelectedObject = o
End Sub
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|