473,699 Members | 2,506 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Docking Form.UserContro l

I have a User control that I load dynamically into a Form. The designer has
no property to let me dock it. How do i Dock it or get it to stretch out to
fill. Setting this.Dock = DockStyle.Fill; in the constructor did not work.
Neither did implementing the resize event.

thanks,
Hananiel
Nov 15 '05 #1
1 9863
100
Hi Hananiel
Setting controls Dock property has to do the work.
The steps you should follow are:
1. Instantiate an objects of your control class.
MyControl ctrl = new MyControl();

2. Set all properties you need as well as the Dock property
ctrl.Dock = DockStyle.Fill;

3. Add the control as a child control to other contol or form

hostCtrl.Suspen dLayout();
hostCtrl.Contro ls.Add(ctrl);
hostCtrl.Resume Layout();

Suspend and resume layout methods pair don't have to be called if you add
only one control but they are very helpful when you add more then one.

Bare in mind that the control classes layout their children in backward
order that mans the las control added will be layouted first so if the host
control have already childern and you add the new control with filling dock
style that control will be layouted first and then the others. So, your
filling cotnrol will be either obscured by the others or will cover the
others. This is not what you want to achieve, I guess. So you have to make
sure that the filling control is always at index 0.
If you have already children of the host control you has to take one step
more when you add the control. You have to move it at index 0. Control
collection doesn't support Insert method and you should do it like this:

hostCtrl.Suspen dLayout();
hostCtrl.Contro ls.Add(ctrl);
hostCtrl.Contro ls.SetChildInde x(ctrl, 0);
hostCtrl.Resume Layout();

HTH
B\rgds
100

"Hananiel" <Ha******@junkm ail.com> wrote in message
news:eH******** ******@TK2MSFTN GP12.phx.gbl...
I have a User control that I load dynamically into a Form. The designer has no property to let me dock it. How do i Dock it or get it to stretch out to fill. Setting this.Dock = DockStyle.Fill; in the constructor did not work.
Neither did implementing the resize event.

thanks,
Hananiel

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
11876
by: David N | last post by:
Hi All, I just wonder if in C#, I can develop a user defined control that can call its parent function which is not yet developed. For example, how do I make my user control call a to-be-developed-function cmdOkay_Click() function as described below. 1. Create an user control that contains an OK button as below Public Class MyButton:System.Windows.Form.UserControl
1
1294
by: Jason | last post by:
Hi I would like a user control/form that can be either called as a dialog (ShowDialog) or embedded in another form (usercontrol). preferably, my dialog/usercontrol accepts an argument that specifies which mode it should be, i.e. embedded or dialog... what is the best way of accomplishing this?
4
9299
by: Dennis Burdett | last post by:
I have a pretty complex control which use to be a C# windows form that I am trying to make into a control that can be dragged onto a VB6 form. I was able to make it into a com class that I could then go to VB6 and add the reference and call the object there without any problems. When I try to make it into a UserControl, I get it to build and it registers itself during the build with no errors BUT I can not add the dll to the vb6...
0
1011
by: Geraldine Hobley | last post by:
Hello I have a problem changing the title of a crownwood docking form called CProjectInfo which is contained within anothe form called mdiClient 'definition in form mdiclien Public Shared CProjectInfo As Conten Setting the title in another form strTitle = "Project Info - Current Project - " & StrHeader & " Current Job - " & CurrJobKe mdiClient.CProjectInfo.FullTitle = strTitl
2
2824
by: Mark Collard | last post by:
The ToolBar control allows you to add toolbar buttons. When you add a button, the button is not only displayed in the toolbar, but also added as a separator control in the form/usercontrol your toolbar exists in. I'm writing my own usercontrol which contains various different controls (e.g. Panel, Button). I would like these controls to be listed in the drop down just above the Properties grid, when a new instance of the usercontrol is...
6
12130
by: MeowCow | last post by:
I have created a UserControl that encapsulates a third party data grid. My goal was to create my own DataSource and DataMember properties that forward the binding to the third party grid, then use binding like normal. The problem I am running into is that my UserControl ends up with a different BindingContext then the ParentForm it is contained in and thus all other controls on the parent form. (I want various controls on the form to...
1
3733
by: DK | last post by:
I have an image list control on a user control that I'm trying to access from the main form. I've tried different code but can't get it. I get an error: Cannot convert type 'System.Windows.Forms.Control' to 'System.Windows.Forms.ImageList' ImageList il = new ImageList(); il = (ImageList)userControlMedia1.Controls.Find("imageListMedia", true); Any ideas??
5
2082
by: Henrik | last post by:
Hello, I'm trying to make an event that will close a usercontrol and open another one. The first user control is for login and when the password have been validated, the event should fire and the event/form would close the usercontrol. The problem is that the form can't see the event with the error "are you missing a using directive or an assembly reference?" The form code: using System; using System.Collections.Generic; using...
5
2503
by: Eitan Mizrahi | last post by:
I see a message on: http://bytes.com/topic/asp-net/answers/334831-winform-control-hosted-ie-fileio-security-exception-please-he I have got the same problem, which I cannot figure out what is the solution for weeks. I have Windows 7 (Home premium edition), framework 3.5 (how can I check that, if gacutil is correct version, if it metters, anyway ...) I am writting on C#. Also on assemblyInfo.cs :
0
8686
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9033
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8911
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8882
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7748
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5872
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.