Solved

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

Posted on 2013-12-19
8
536 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
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

749 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