I want my custom UserControl to size and resize with its parent, a Form. But
when I use the code
Size=Parent.Cli entSize;
in the constructor of myUserControl, Parent is null and the operation fails.
What is the proper place to put this code? 4 8882
Well, Size is a struct (value-type), so this wouldn't really do what you
want anyway...
Perhaps you should look more at docking and anchoring?
Marc
Hi,
Most probably it is done in the InitializeCompo nent method when you add the
control to the Controls collection
I also suggest you to use docking/anchoring.
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Martijn Mulder" <i@mwrote in message
news:44******** *************** @news.wanadoo.n l...
>I want my custom UserControl to size and resize with its parent, a Form. But when I use the code
Size=Parent.Cli entSize;
in the constructor of myUserControl, Parent is null and the operation
fails. What is the proper place to put this code?
Thank you all,
docking/anchoring, it must be a lot like Java's LayoutManagers. What classes
and/or namespaces do I need to look into?
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
schreef in bericht news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
Hi,
Most probably it is done in the InitializeCompo nent method when you add
the control to the Controls collection
I also suggest you to use docking/anchoring.
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Martijn Mulder" <i@mwrote in message
news:44******** *************** @news.wanadoo.n l...
>>I want my custom UserControl to size and resize with its parent, a Form. But when I use the code
Size=Parent.Cl ientSize;
in the constructor of myUserControl, Parent is null and the operation fails. What is the proper place to put this code?
They are properties on the control instance; e.g. to fill the available
space (which sounds like what you want):
control.Dock = DockStyle.Fill; // could be this.Dock in a ctor
If, however, you want to just maintain the distance from the edges (w/o
filling everything), then
control.Anchor = AnchorStyles.To p | AnchorStyles.Bo ttom| AnchorStyles.Le ft |
AnchorStyles.Ri ght;
(or remove the edges you don't want to stick to; Top | Left is common, as is
Top | Left | Right)
Marc This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: balg |
last post by:
An ActiveX control has a call to "UserControl.Parent" which
fails when it is interopped and added to a .Net Form.
Is there any way to access to .Net parent control/it's interfaces
from VB6 ActiveX Control.
Thanks,
BalG
|
by: Chris |
last post by:
I have a fairly straight-forward form that loads preferences upon
running, and saves them upon exiting. Included in the preferences are
things like window size & location, working directory, etc. There
seems to be a problem with the way the size of the form is being
calculated. If you run/exit/run/exit a bunch of times, the form keeps...
|
by: Ben Amada |
last post by:
Hello,
I have a user control which will be dynamically loaded from one of two
parent ASPX webforms. Within the user control I'd like to be able to access
a property from the parent webform. One problem I'm having is that I don't
know the type of the parent webform until run-time. Is this possible? And
if so, how can I do this?
Thank...
|
by: Geoff Jones |
last post by:
Hi
Suppose I have two forms: Form1 and Form2. I create and show an instance of
Form2 in the code of Form1 e.g.
Dim myForm2 = New Form2
myForm2.Show()
How do I tell myForm2 that Form1 is its parent? That is, when I look at
either "Parent" or "ParentForm" in Form2, they both show "Nothing".
|
by: Gary Shell |
last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852 (http://support.microsoft.com/kb/810852), but then I realized that the hotfix mentioned was in .Net v1.1, which I am using.
I took the sample from that...
| |
by: Steve Kershaw |
last post by:
I have this web page that has on it a user control. I have a need to
access a method that resides in the parent web page from within this
user control. It seems that there should be a way to do this!
Thanks in advance for your help.
Steve
|
by: lotus |
last post by:
HI All..
I'm realtively new to C#.
I have MainForm which includes Parent usercontol, and this parent
usercontrol also contains child usercontrol.
MainForm --> Parent usercontrol --> child usercontrol
Parent usercontol has one button to change the child usercontorl's
variable.
|
by: versatile |
last post by:
Hi,
I am using a vb 6.0 user control in my .net application.
Usercontrol.Parent property of the user control is failing as it is getting the reference of the .net form.
How can i make it work?
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |