This works properly:
1. Create a new Form and set it's size to 229, 474.
2. Drag a Panel to the form and set the following properties:
Size = 216, 438
Location = 3,1
Anchor = Top, Bottom
3. Add a PictureBox control to the top of the panel and set the following
properties:
Size = 210, 56
Location = 3,2
Anchor = Top, Left
and then stick a image into the PictureBox
4. Add a LinkLabel control to the bottom of the panel and set the following
properties:
Text = "LinkLabel Test"
Size = 126,13
Location = 52, 413
Anchor = Bottom, Left
Run the program and try resizing the form. You'll notice as you make the
form wider, the panel stays centered inside the form and if you expand the
form vertically the link label will move up and down properly. So everything
is working as it should.
Now, I am creating a User Control which I just copied the above Panel to the
UserControl and adding it to the Form like this:
Dim c As New UserControl1
Me.Controls.Add (c)
and run the program. You'll notice the anchoring no longer works and as you
expand the form, the UserControl stays stationary in the top left corner of
the form.
How do I get the UserControl to behave just like the Panel being added to
the form?
This has been very frusturating for me over the past few days since I have
tried setting the anchor programatically when creating the control and adding
it to the form like this:
Dim c As New UserControl1
c.Anchor = AnchorStyle.Top And AnchorStyle.Bot tom
Me.Controls.Add (c)
That just causes the UserControl to center itself on the Form and the Panel
inside the UserControl ignores the anchors set.
What am I doing wrong?
Please help! 3 5166
c.Anchor = AnchorStyle.Top And AnchorStyle.Bot tom
Try: c.Anchor = AnchorStyle.Top OR AnchorStyle.Bot tom
--
Greetings,
Josip Medved http://www.jmedved.com
Josip,
You be the man! That worked!
It was just the syntax all along, geez.
"Josip Medved" wrote:
c.Anchor = AnchorStyle.Top And AnchorStyle.Bot tom
Try: c.Anchor = AnchorStyle.Top OR AnchorStyle.Bot tom
--
Greetings,
Josip Medved http://www.jmedved.com
How do I get my UserControl to resize itself properly after I remove it from
the form and then add it again.
If I resize form and add the UserControl it appears in the upper left hand
corner and looses it's anchor capabilities.
"Josip Medved" wrote:
c.Anchor = AnchorStyle.Top And AnchorStyle.Bot tom
Try: c.Anchor = AnchorStyle.Top OR AnchorStyle.Bot tom
--
Greetings,
Josip Medved http://www.jmedved.com
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Peter Olcott |
last post by:
www.halting-problem.com
|
by: Jon Davis |
last post by:
If I have a class with a virtual method, and a child class that overrides
the virtual method, and then I create an instance of the child class AS A
base class...
BaseClass bc = new ChildClass();
.... and then call the virtual method, why is it that the base class's method
is called instead of the overridden method? How do I fix this if I don't
know at runtime what the child class is? I'm using
Activator.CreateInstance() to load the...
|
by: Brian Conway |
last post by:
I have a webform that I have a datagrid on that I want a button at the
bottom of the grid to maintain its position with the datagrid, if the grid
grows large then button needs to move down with it, and if it is smaller it
needs to move up. Everything regarding anchoring that I have found is with
Windows Forms, is there any way to do this with a Web Form?
|
by: Mad Joe |
last post by:
Hi!
I have a window form that contains 4 elements (2x2) on one panel.
Those 4 elements are GroupBoxes of the exact same size, sorted like this:
groupBox1 groupBox2
groupBox3 groupBox4
While resizing a Form window manually, I would like to resize
automatically each groupBox by keeping the same ratio:
Width of each groupBox = 50% of Panel-width
|
by: Ammar |
last post by:
Dear All,
I'm facing a small problem.
I have a portal web site, that contains articles, for each article, the end
user can send a comment about the article.
The problem is:
I the comment length is more that 1249 bytes, then the progress bar of the
browser will move too slow and then displaying that the page not found!!!!
If the message is less than or equal to 1249 then no problem.
| |
by: daveryan78 |
last post by:
Hi all,
I've been getting a strange problem with anchoring on my forms. I have
a form where I put on a tabControl. I set it's anchoring to Top,
Bottom, Left, Right. I put a number of tabPages on to the control. On
the first tab I put textBoxes and comboBoxes. I set all their widths to
655 and their anchoring to Top, Left, Right.
When I run the app, the form appears and all the textboxes and
comboBoxes have truncated from the right, the...
|
by: Steve |
last post by:
I have two group boxes containing labels and textboxes that are next too
each other. I want the group boxes and labels and textboxes to remain
portionally the same as the form is resized.
I've set the group boxes to be anchored left, right, top, and bottom, the
labels to be left, right, top, and the textboxes to be anchored left,
right,top, and bottom.
But when I try to manually resize the form, the group boxes overlap. How do
I get...
|
by: marfi95 |
last post by:
My application consists of basically a treeview on the left side,
along with a panel control that takes up the right side. When nodes
are clicked on the left, the data on the right side of the panel is
changed based on that type.
What I'm using are usercontrols, so I can do the visual design of them
in a separate window. when the node is clicked, I assign the parent
of the usercontrol to the panel control that is on the right side of...
|
by: sklett |
last post by:
I've read several articles/blogs/threads about anchoring/docking child
controls in a FlowLayoutPanel. It sounds like it *should* work, but I can't
get it to work for the life of me.
Jon Skeet: I've created a short and complete sample to illustrate the
problem. Beat you to it! :0)
I would really appreciate if anyone could take a look at this and tell me
what the magic trick is to make this work. All I want is to have the child...
|
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...
|
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,...
| |
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...
|
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,...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |