Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 541
  • Last Modified:

winform panel displays control from .dll, control won't resize

I have a C++ windows forms project with a panel.

Loaded into the panel is a custom control that was built in a separate Visual Studio solution which created a *.dll file. The control is dynamically loaded from this *.dll file into the panel at run time.

The panel resizes when the user resizes the window.

But the control won't resize. It resizes in the Visual Studio designer, but won't resize when loaded into this panel.


I'm pondering maybe the 'resize' message just isn't getting sent back to the external control?
0
deleyd
Asked:
deleyd
  • 4
  • 3
1 Solution
 
Kalpesh ChhatralaSoftware ConsultantCommented:
did you added Dock or Anchoring in your form controls  ?
0
 
deleydAuthor Commented:
I created a test VB.net winforms project consisting of just a Form1, Panel1 in the Form1, load the control from the .dll into the Panel1. Control doesn't resize.

Panel1 is anchored on all 4 sides.

Tried fiddlling with the control's AutoSize and AutoSizeMode to no avail. Tried False, True, GrowOnly, GrowAndShrink. Doesn't seem to matter.
control.gif
panel1.gif
0
 
Kalpesh ChhatralaSoftware ConsultantCommented:
send me your sample form.
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
deleydAuthor Commented:
OK I did a test, and discovered:

Single Visual Studio "solution" with one project defining a user control, and another project defining a simple form to load that control into; the control resizes when I resize the form.

However, If I create a separate Visual Studio "solution" with a simple form to load the control from the *.dll file (generated from the previous Visual Studio solution), then the control loads into my form but does not resize.
0
 
Kalpesh ChhatralaSoftware ConsultantCommented:
may be some issue on your Control (loaded from dll)

may be your user control reside in panel and in that panel anchoring/docking value not available. (loaded from Dll)
0
 
deleydAuthor Commented:
I got it. This was a tricky one. After dynamically obtaining the control from the .dll, I need to set the .dock attibute of the control to Fill (line 10):
Try
    Dim assemName = "C:\Users\Public\VS\test\WindowsFormsControlLibrary1\WindowsFormsControlLibrary1\bin\Debug\WindowsFormsControlLibrary1.dll"
    Dim fullAssemName = String.Format("file://{0}", assemName)
    Dim fullTypeName = String.Format("{0}.{1}", "WindowsFormsControlLibrary1", "UserControl1")
    Dim assem = If(File.Exists(assemName), Assembly.LoadFrom(fullAssemName), Nothing)
    If Not assem Is Nothing Then
        Dim _type = assem.GetType(fullTypeName, True)
        If (Not _type Is Nothing) Then
            Dim ctl = CType(Activator.CreateInstance(_type), Control)
            ctl.Dock = System.Windows.Forms.DockStyle.Fill
            Me.Controls.Add(ctl)
        End If
    End If
Catch ex As Exception
    MsgBox(ex.Message + ex.StackTrace)
End Try

Open in new window

0
 
Kalpesh ChhatralaSoftware ConsultantCommented:
Great :)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now