Solved

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

Posted on 2013-12-19
8
538 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
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

 

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

RHCE - Red Hat OpenStack Prep Course

This course will provide in-depth training so that students who currently hold the EX200 & EX210 certifications can sit for the EX310 exam. Students will learn how to deploy & manage a full Red Hat environment with Ceph block storage, & integrate Ceph into other OpenStack service

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

623 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