Solved

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

Posted on 2013-12-19
8
531 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
  • 4
  • 3
8 Comments
 
LVL 16

Expert Comment

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

Author Comment

by:deleyd
Comment Utility
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
Comment Utility
send me your sample form.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:deleyd
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Great :)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now