Solved

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

Posted on 2013-12-19
8
537 Views
Last Modified: 2013-12-25
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
Comment
Question by:deleyd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 16

Expert Comment

by:Kalpesh Chhatrala
ID: 39731255
did you added Dock or Anchoring in your form controls  ?
0
 

Author Comment

by:deleyd
ID: 39735258
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
 
LVL 16

Expert Comment

by:Kalpesh Chhatrala
ID: 39735550
send me your sample form.
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:deleyd
ID: 39736910
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
 
LVL 16

Accepted Solution

by:
Kalpesh Chhatrala earned 500 total points
ID: 39737333
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
 

Author Comment

by:deleyd
ID: 39738915
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
 
LVL 16

Expert Comment

by:Kalpesh Chhatrala
ID: 39738945
Great :)
0

Featured Post

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question