I need to create a form from this web service
http://24.163.239.122/wsprojecttrack...erobjects.asmx
if you call getloginscreen there is a field called screendescription
that field screendescription has the form code I am trying to create at
runtime
the code that is in the field screendecription is
Imports System.Windows.Forms
Public Class clsLoginScreen
Inherits System.Windows.Forms.Form
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Private components As System.ComponentModel.IContainer
Friend WithEvents NicePanel1 As PureComponents.NicePanel.NicePanel
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Dim ContainerImage1 As PureComponents.NicePanel.ContainerImage = New
PureComponents.NicePanel.ContainerImage
Dim HeaderImage1 As PureComponents.NicePanel.HeaderImage = New
PureComponents.NicePanel.HeaderImage
Dim HeaderImage2 As PureComponents.NicePanel.HeaderImage = New
PureComponents.NicePanel.HeaderImage
Dim PanelStyle1 As PureComponents.NicePanel.PanelStyle = New
PureComponents.NicePanel.PanelStyle
Dim ContainerStyle1 As PureComponents.NicePanel.ContainerStyle = New
PureComponents.NicePanel.ContainerStyle
Dim PanelHeaderStyle1 As PureComponents.NicePanel.PanelHeaderStyle = New
PureComponents.NicePanel.PanelHeaderStyle
Dim PanelHeaderStyle2 As PureComponents.NicePanel.PanelHeaderStyle = New
PureComponents.NicePanel.PanelHeaderStyle
Me.NicePanel1 = New PureComponents.NicePanel.NicePanel
Me.SuspendLayout()
Me.NicePanel1.BackColor = System.Drawing.Color.Transparent
ContainerImage1.Alignment = System.Drawing.ContentAlignment.BottomRight
ContainerImage1.ClipArt = PureComponents.NicePanel.ImageClipArt.None
ContainerImage1.Image = Nothing
ContainerImage1.Size = PureComponents.NicePanel.ContainerImageSize.Small
ContainerImage1.Transparency = 50
Me.NicePanel1.ContainerImage = ContainerImage1
HeaderImage1.ClipArt = PureComponents.NicePanel.ImageClipArt.None
HeaderImage1.Image = Nothing
Me.NicePanel1.FooterImage = HeaderImage1
Me.NicePanel1.FooterText = "PureComponents NicePanel for .NET WinForms
V1.0."
Me.NicePanel1.ForeColor = System.Drawing.Color.Black
HeaderImage2.ClipArt =
PureComponents.NicePanel.ImageClipArt.PureComponen ts
HeaderImage2.Image = Nothing
Me.NicePanel1.HeaderImage = HeaderImage2
Me.NicePanel1.HeaderText = "NicePanel1"
Me.NicePanel1.IsExpanded = True
Me.NicePanel1.Location = New System.Drawing.Point(0, 0)
Me.NicePanel1.Name = "NicePanel1"
Me.NicePanel1.OriginalFooterVisible = True
Me.NicePanel1.OriginalHeight = 0
Me.NicePanel1.Size = New System.Drawing.Size(400, 264)
ContainerStyle1.BackColor = System.Drawing.Color.FromArgb(CType(142,
Byte), CType(179, Byte), CType(231, Byte))
ContainerStyle1.BaseColor = System.Drawing.Color.Transparent
ContainerStyle1.BorderColor = System.Drawing.Color.FromArgb(CType(1,
Byte), CType(45, Byte), CType(150, Byte))
ContainerStyle1.BorderStyle = PureComponents.NicePanel.BorderStyle.Solid
ContainerStyle1.CaptionAlign = PureComponents.NicePanel.CaptionAlign.Left
ContainerStyle1.FadeColor = System.Drawing.Color.FromArgb(CType(217,
Byte), CType(232, Byte), CType(252, Byte))
ContainerStyle1.FillStyle =
PureComponents.NicePanel.FillStyle.DiagonalForward
ContainerStyle1.FlashItemBackColor = System.Drawing.Color.Red
ContainerStyle1.FocusItemBackColor =
System.Drawing.Color.FromArgb(CType(255, Byte), CType(255, Byte), CType(128,
Byte))
ContainerStyle1.Font = New System.Drawing.Font("Microsoft Sans Serif",
8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
ContainerStyle1.ForeColor = System.Drawing.Color.Black
ContainerStyle1.Shape = PureComponents.NicePanel.Shape.Squared
PanelStyle1.ContainerStyle = ContainerStyle1
PanelHeaderStyle1.BackColor = System.Drawing.Color.FromArgb(CType(9,
Byte), CType(42, Byte), CType(127, Byte))
PanelHeaderStyle1.ButtonColor = System.Drawing.Color.FromArgb(CType(172,
Byte), CType(191, Byte), CType(227, Byte))
PanelHeaderStyle1.FadeColor = System.Drawing.Color.FromArgb(CType(102,
Byte), CType(145, Byte), CType(215, Byte))
PanelHeaderStyle1.FillStyle =
PureComponents.NicePanel.FillStyle.HorizontalFadin g
PanelHeaderStyle1.FlashBackColor =
System.Drawing.Color.FromArgb(CType(243, Byte), CType(122, Byte), CType(1,
Byte))
PanelHeaderStyle1.FlashFadeColor =
System.Drawing.Color.FromArgb(CType(255, Byte), CType(215, Byte), CType(159,
Byte))
PanelHeaderStyle1.FlashForeColor = System.Drawing.Color.White
PanelHeaderStyle1.Font = New System.Drawing.Font("Microsoft Sans Serif",
8.25!)
PanelHeaderStyle1.ForeColor = System.Drawing.Color.FromArgb(CType(169,
Byte), CType(198, Byte), CType(237, Byte))
PanelHeaderStyle1.Size = PureComponents.NicePanel.PanelHeaderSize.Small
PanelStyle1.FooterStyle = PanelHeaderStyle1
PanelHeaderStyle2.BackColor = System.Drawing.Color.FromArgb(CType(102,
Byte), CType(145, Byte), CType(215, Byte))
PanelHeaderStyle2.ButtonColor = System.Drawing.Color.FromArgb(CType(172,
Byte), CType(191, Byte), CType(227, Byte))
PanelHeaderStyle2.FadeColor = System.Drawing.Color.FromArgb(CType(9,
Byte), CType(42, Byte), CType(127, Byte))
PanelHeaderStyle2.FillStyle =
PureComponents.NicePanel.FillStyle.VerticalFading
PanelHeaderStyle2.FlashBackColor =
System.Drawing.Color.FromArgb(CType(243, Byte), CType(122, Byte), CType(1,
Byte))
PanelHeaderStyle2.FlashFadeColor =
System.Drawing.Color.FromArgb(CType(255, Byte), CType(215, Byte), CType(159,
Byte))
PanelHeaderStyle2.FlashForeColor = System.Drawing.Color.White
PanelHeaderStyle2.Font = New System.Drawing.Font("Microsoft Sans Serif",
9.75!, System.Drawing.FontStyle.Bold)
PanelHeaderStyle2.ForeColor = System.Drawing.Color.FromArgb(CType(215,
Byte), CType(230, Byte), CType(251, Byte))
PanelHeaderStyle2.Size = PureComponents.NicePanel.PanelHeaderSize.Medium
PanelStyle1.HeaderStyle = PanelHeaderStyle2
Me.NicePanel1.Style = PanelStyle1
Me.NicePanel1.TabIndex = 0
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(400, 273)
Me.Controls.Add(Me.NicePanel1)
Me.Name = "clsLoginScreen"
Me.Text = "clsLoginScreen"
Me.ResumeLayout(False)
End Sub
Private Sub clsLoginScreen_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub End Class
So that is the code that is being pulled out of the database
It is just a plain form with a nicepanel on it. Which intails need the
nicepanel assembly added.
Here is my code I am using to try to get the form to compile at run time
I make a direct call to the database rather then hitting the web service in
the code below.
Dim cn As OleDbConnection
Dim sConnString As String = _
"Provider=SQLOLEDB;server=vsdev;UID=sa;PWD=sa;data base=projecttracker"
cn = New OleDb.OleDbConnection(sConnString)
Dim ds As New DataSet
Dim cm As New OleDbCommand("select * from tblscreen", cn)
Dim a As New OleDbDataAdapter(cm)
cn.Open()
a.Fill(ds)
cn.Close()
Dim provider As Microsoft.VisualBasic.VBCodeProvider
Dim compiler As System.CodeDom.Compiler.ICodeCompiler
Dim params As System.CodeDom.Compiler.CompilerParameters
Dim results As System.CodeDom.Compiler.CompilerResults
Dim scriptType As Type
Dim instance As Object
Dim rslt As Object
params = New System.CodeDom.Compiler.CompilerParameters
params.GenerateInMemory = True 'Assembly is created in memory
params.TreatWarningsAsErrors = False
params.WarningLevel = 4
'Put any references you need here - even you own dll's, if you want
to use one
Dim refs() As String = {"System.IO", "System.dll",
"Microsoft.VisualBasic.dll", "PureComponents.NicePanel.NicePanel",
"System.Windows.Forms"}
params.ReferencedAssemblies.AddRange(refs)
provider = New Microsoft.VisualBasic.VBCodeProvider
compiler = provider.CreateCompiler
Try
results = compiler.CompileAssemblyFromSource(params,
ds.Tables(0).Rows(0).Item("screendescription").ToS tring)
Catch ex As Exception
End Try
If results.Errors.Count = 0 Then 'No compile errors or
warnings...
mAssembly = results.CompiledAssembly
End If
'Get the type from the assembly. This will allow us access to
'all the properties and methods
Dim err As System.CodeDom.Compiler.CompilerError
For Each err In results.Errors
MsgBox(String.Format( _
"Line {0}, Col {1}: Error {2} - {3}", _
err.Line, err.Column, err.ErrorNumber, err.ErrorText))
Next
scriptType = mAssembly.GetType("clsScreens.clsLoginScreen")
'Set up an array of objects to pass as arguments.
Dim args() As Object = {""}
'And call the static function
rslt = scriptType.InvokeMember("StaticFunction", _
System.Reflection.BindingFlags.InvokeMethod Or _
System.Reflection.BindingFlags.Public Or _
System.Reflection.BindingFlags.Static, _
Nothing, Nothing, args)
So as you can see I pull the form out of the database. It is a windows form.
But I think that I missing some stuff. When you create a form you get a .vb
file and a ..resx file which i am not createing the resx file.
I did not think that you needed to create that file.
If you have any thoughts please let me know
Thank you
CC