473,761 Members | 9,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Anything better than "Anchor"?

Ok, I celebrate and rejoice in the Anchor property. So wonderful compared
to the horrible 'resize' code I had to write in VB6, there is just no end to
the wonders of VB.NET..... uh, ok..... BUT...

I have a form with a lot of controls side by side, etc. The Anchor is
really only useful to resize 1 control on each line (and move all the
others). BUT, does anyone have any articles or other ways to do this?

For example, I am working on a piece of code that is similar to Anchor, and
is an 'Extender' that allows you to specify specifc a related control,
specify your edge and its edge and then do the math from there (if that
makes sense).

So, for example, the signature looks something like:
control.Extende dAnchor(related control As Object, myedge as AnchorStyles,
relatededge as AnchorStyles)

Where is is binding the specified edges of two specified controls (or the
form).
This is particularly useful in keeping textbox labels positioned over
textboxes where there are multiple across.

I just want to know if someone has already done this? Or has *anything*
better than just the Anchor property?
Nov 20 '05 #1
6 6661
What exactly is your problem? What can you not do with the Anchor property?

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Richard Brown" <rb****@easylif t.org> wrote in message
news:Oe******** ******@TK2MSFTN GP10.phx.gbl...
Ok, I celebrate and rejoice in the Anchor property. So wonderful compared
to the horrible 'resize' code I had to write in VB6, there is just no end to the wonders of VB.NET..... uh, ok..... BUT...

I have a form with a lot of controls side by side, etc. The Anchor is
really only useful to resize 1 control on each line (and move all the
others). BUT, does anyone have any articles or other ways to do this?

For example, I am working on a piece of code that is similar to Anchor, and is an 'Extender' that allows you to specify specifc a related control,
specify your edge and its edge and then do the math from there (if that
makes sense).

So, for example, the signature looks something like:
control.Extende dAnchor(related control As Object, myedge as AnchorStyles,
relatededge as AnchorStyles)

Where is is binding the specified edges of two specified controls (or the
form).
This is particularly useful in keeping textbox labels positioned over
textboxes where there are multiple across.

I just want to know if someone has already done this? Or has *anything*
better than just the Anchor property?

Nov 20 '05 #2
Ok, for example, lets say that you have three text boxes, side by side,
First Name, Middle Initial, Last Name.
The middle one should just float and stay the same size, the left should
grow and be fixed at the left edge, the right one should grow, but be fixed
at the right edge.

How can the anchor property accomodate that?
Its almost like the middle text box needs to be 'anchored' to the
width-center of the form, the left textbox to the left of the form and right
of the middle text box, and the right text box anchored to right edge of the
middle text box and right edge of the form.

I'm not saying I have thought all of this through completely, but situations
*like* this don't seem to be able to be handled by 'anchor'.

"Tom Spink" <th**********@n tlworld.com> wrote in message
news:O2******** ******@TK2MSFTN GP10.phx.gbl...
What exactly is your problem? What can you not do with the Anchor property?
--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Richard Brown" <rb****@easylif t.org> wrote in message
news:Oe******** ******@TK2MSFTN GP10.phx.gbl...
Ok, I celebrate and rejoice in the Anchor property. So wonderful compared to the horrible 'resize' code I had to write in VB6, there is just no end
to
the wonders of VB.NET..... uh, ok..... BUT...

I have a form with a lot of controls side by side, etc. The Anchor is
really only useful to resize 1 control on each line (and move all the
others). BUT, does anyone have any articles or other ways to do this?

For example, I am working on a piece of code that is similar to Anchor,

and
is an 'Extender' that allows you to specify specifc a related control,
specify your edge and its edge and then do the math from there (if that
makes sense).

So, for example, the signature looks something like:
control.Extende dAnchor(related control As Object, myedge as AnchorStyles,
relatededge as AnchorStyles)

Where is is binding the specified edges of two specified controls (or

the form).
This is particularly useful in keeping textbox labels positioned over
textboxes where there are multiple across.

I just want to know if someone has already done this? Or has *anything*
better than just the Anchor property?


Nov 20 '05 #3
Richard,
In case you didn't know you handle the Layout event to do your own layout of
controls. (or override the OnLayout method). The layout event has
SuspendLayout & ResumeLayout so you can control when you layout controls...

For side by side controls I find putting them into a Panel (or their own
user control :-)) helps. For example, at my last job, we had a form that had
3 or 4 buttons centered on the bottom of the form. Placing the 3 or 4
buttons in a panel, then centering the panel on the control, greatly
simplified things. The panel was anchored to only the bottom, keeping it a
fixed distance to the bottom, because the side were not anchored it stayed
centered to the project. You can also use the layout event of the panel to
the contained controls resize in relation to each other, as the panel is
resized.

For my current project I have a user control with two contained controls.
One is docked to the top, the other is docked to the bottom. In the layout
event, I change the height of both, so they both always take up half the
space of the user control.

If you have not already seen it, the following article provides a custom
layout engine for Windows Forms:

http://msdn.microsoft.com/library/de...aywinforms.asp

The following article describes the panel trick:
http://www.devx.com/dotnet/Article/6964/0/page/1

If you search google for "windows forms layout" you get a number of 'good'
hits'

Hope this helps
Jay

"Richard Brown" <rb****@easylif t.org> wrote in message
news:Oe******** ******@TK2MSFTN GP10.phx.gbl...
Ok, I celebrate and rejoice in the Anchor property. So wonderful compared
to the horrible 'resize' code I had to write in VB6, there is just no end to the wonders of VB.NET..... uh, ok..... BUT...

I have a form with a lot of controls side by side, etc. The Anchor is
really only useful to resize 1 control on each line (and move all the
others). BUT, does anyone have any articles or other ways to do this?

For example, I am working on a piece of code that is similar to Anchor, and is an 'Extender' that allows you to specify specifc a related control,
specify your edge and its edge and then do the math from there (if that
makes sense).

So, for example, the signature looks something like:
control.Extende dAnchor(related control As Object, myedge as AnchorStyles,
relatededge as AnchorStyles)

Where is is binding the specified edges of two specified controls (or the
form).
This is particularly useful in keeping textbox labels positioned over
textboxes where there are multiple across.

I just want to know if someone has already done this? Or has *anything*
better than just the Anchor property?

Nov 20 '05 #4
Gosh darn Jay, I knew someone on here had *all* the answers!
Thank you, I have not run across the 'layout' event yet and it sounds
exactly (almost) just like I need.
At least, that event seems to be the proper place to perform the coding (I
guess similar to placing the coding in the Resize event in Classic VB).

I think I would still have to have some sort of 'mapped linking' or
something if I wanted to make that code generic though.
I'm off to jump into the SDK docs to look up all of this, thanks again.

"Jay B. Harlow [MVP - Outlook]" <Ja********@ema il.msn.com> wrote in message
news:ex******** ********@TK2MSF TNGP10.phx.gbl. ..
Richard,
In case you didn't know you handle the Layout event to do your own layout of controls. (or override the OnLayout method). The layout event has
SuspendLayout & ResumeLayout so you can control when you layout controls...
For side by side controls I find putting them into a Panel (or their own
user control :-)) helps. For example, at my last job, we had a form that had 3 or 4 buttons centered on the bottom of the form. Placing the 3 or 4
buttons in a panel, then centering the panel on the control, greatly
simplified things. The panel was anchored to only the bottom, keeping it a
fixed distance to the bottom, because the side were not anchored it stayed
centered to the project. You can also use the layout event of the panel to
the contained controls resize in relation to each other, as the panel is
resized.

For my current project I have a user control with two contained controls.
One is docked to the top, the other is docked to the bottom. In the layout
event, I change the height of both, so they both always take up half the
space of the user control.

If you have not already seen it, the following article provides a custom
layout engine for Windows Forms:

http://msdn.microsoft.com/library/de...aywinforms.asp
The following article describes the panel trick:
http://www.devx.com/dotnet/Article/6964/0/page/1

If you search google for "windows forms layout" you get a number of 'good'
hits'

Hope this helps
Jay

"Richard Brown" <rb****@easylif t.org> wrote in message
news:Oe******** ******@TK2MSFTN GP10.phx.gbl...
Ok, I celebrate and rejoice in the Anchor property. So wonderful compared to the horrible 'resize' code I had to write in VB6, there is just no end
to
the wonders of VB.NET..... uh, ok..... BUT...

I have a form with a lot of controls side by side, etc. The Anchor is
really only useful to resize 1 control on each line (and move all the
others). BUT, does anyone have any articles or other ways to do this?

For example, I am working on a piece of code that is similar to Anchor,

and
is an 'Extender' that allows you to specify specifc a related control,
specify your edge and its edge and then do the math from there (if that
makes sense).

So, for example, the signature looks something like:
control.Extende dAnchor(related control As Object, myedge as AnchorStyles,
relatededge as AnchorStyles)

Where is is binding the specified edges of two specified controls (or

the form).
This is particularly useful in keeping textbox labels positioned over
textboxes where there are multiple across.

I just want to know if someone has already done this? Or has *anything*
better than just the Anchor property?


Nov 20 '05 #5
Richard,
The resize event among other things calls the PerformLayout method.

The PerformLayout method raises the Layout event, based on whether or not
SuspendLayout has been called without a matching ResumeLayout.

This allows the constructor & load events to SuspendLayout, make a bunch of
changes then ResumeLayout and all your controls will change, otherwise you
have the risk of repeated 'cascading' changes. which would slow everything
down.

Personally I think developing an enhanced anchor control, using a Property
Extender as you initially stated is a good model to follow, I believe that
is the model the first article uses.

The other option is more of a Strategy Pattern. Of course you Property
Extender could support a Strategy.

Hope this helps
Jay

"Richard Brown" <rb****@easylif t.org> wrote in message
news:en******** ********@TK2MSF TNGP09.phx.gbl. ..
Gosh darn Jay, I knew someone on here had *all* the answers!
Thank you, I have not run across the 'layout' event yet and it sounds
exactly (almost) just like I need.
At least, that event seems to be the proper place to perform the coding (I
guess similar to placing the coding in the Resize event in Classic VB).

I think I would still have to have some sort of 'mapped linking' or
something if I wanted to make that code generic though.
I'm off to jump into the SDK docs to look up all of this, thanks again.

"Jay B. Harlow [MVP - Outlook]" <Ja********@ema il.msn.com> wrote in message news:ex******** ********@TK2MSF TNGP10.phx.gbl. ..
Richard,
In case you didn't know you handle the Layout event to do your own layout
of
controls. (or override the OnLayout method). The layout event has
SuspendLayout & ResumeLayout so you can control when you layout

controls...

For side by side controls I find putting them into a Panel (or their own
user control :-)) helps. For example, at my last job, we had a form that

had
3 or 4 buttons centered on the bottom of the form. Placing the 3 or 4
buttons in a panel, then centering the panel on the control, greatly
simplified things. The panel was anchored to only the bottom, keeping it a fixed distance to the bottom, because the side were not anchored it stayed centered to the project. You can also use the layout event of the panel to the contained controls resize in relation to each other, as the panel is
resized.

For my current project I have a user control with two contained controls. One is docked to the top, the other is docked to the bottom. In the layout event, I change the height of both, so they both always take up half the
space of the user control.

If you have not already seen it, the following article provides a custom
layout engine for Windows Forms:

http://msdn.microsoft.com/library/de...aywinforms.asp

The following article describes the panel trick:
http://www.devx.com/dotnet/Article/6964/0/page/1

If you search google for "windows forms layout" you get a number of 'good' hits'

Hope this helps
Jay

"Richard Brown" <rb****@easylif t.org> wrote in message
news:Oe******** ******@TK2MSFTN GP10.phx.gbl...
Ok, I celebrate and rejoice in the Anchor property. So wonderful compared to the horrible 'resize' code I had to write in VB6, there is just no end
to
the wonders of VB.NET..... uh, ok..... BUT...

I have a form with a lot of controls side by side, etc. The Anchor is
really only useful to resize 1 control on each line (and move all the
others). BUT, does anyone have any articles or other ways to do this?

For example, I am working on a piece of code that is similar to Anchor, and
is an 'Extender' that allows you to specify specifc a related control,
specify your edge and its edge and then do the math from there (if

that makes sense).

So, for example, the signature looks something like:
control.Extende dAnchor(related control As Object, myedge as AnchorStyles, relatededge as AnchorStyles)

Where is is binding the specified edges of two specified controls (or

the form).
This is particularly useful in keeping textbox labels positioned over
textboxes where there are multiple across.

I just want to know if someone has already done this? Or has *anything* better than just the Anchor property?



Nov 20 '05 #6
I've read that first article and had reminiscent (sp?) dreams of the Java
Programmer Certification tests -- the layouts they model are... umm...
EXACTLY the same.... gee, wonder why.

But its a great starting point and I am going to work on something in that
type of framework. Most notably, I took an interest in the 'Spring' format,
based on percentages, which would kind of work out the kinks with the
'anchoring to other controls'.

"Jay B. Harlow [MVP - Outlook]" <Ja********@ema il.msn.com> wrote in message
news:e4******** ********@TK2MSF TNGP10.phx.gbl. ..
Richard,
The resize event among other things calls the PerformLayout method.

The PerformLayout method raises the Layout event, based on whether or not
SuspendLayout has been called without a matching ResumeLayout.

This allows the constructor & load events to SuspendLayout, make a bunch of changes then ResumeLayout and all your controls will change, otherwise you
have the risk of repeated 'cascading' changes. which would slow everything
down.

Personally I think developing an enhanced anchor control, using a Property
Extender as you initially stated is a good model to follow, I believe that
is the model the first article uses.

The other option is more of a Strategy Pattern. Of course you Property
Extender could support a Strategy.

Hope this helps
Jay

"Richard Brown" <rb****@easylif t.org> wrote in message
news:en******** ********@TK2MSF TNGP09.phx.gbl. ..
Gosh darn Jay, I knew someone on here had *all* the answers!
Thank you, I have not run across the 'layout' event yet and it sounds
exactly (almost) just like I need.
At least, that event seems to be the proper place to perform the coding (I
guess similar to placing the coding in the Resize event in Classic VB).

I think I would still have to have some sort of 'mapped linking' or
something if I wanted to make that code generic though.
I'm off to jump into the SDK docs to look up all of this, thanks again.

"Jay B. Harlow [MVP - Outlook]" <Ja********@ema il.msn.com> wrote in message
news:ex******** ********@TK2MSF TNGP10.phx.gbl. ..
Richard,
In case you didn't know you handle the Layout event to do your own layout
of
controls. (or override the OnLayout method). The layout event has
SuspendLayout & ResumeLayout so you can control when you layout

controls...

For side by side controls I find putting them into a Panel (or their own user control :-)) helps. For example, at my last job, we had a form that had
3 or 4 buttons centered on the bottom of the form. Placing the 3 or 4
buttons in a panel, then centering the panel on the control, greatly
simplified things. The panel was anchored to only the bottom, keeping
it a fixed distance to the bottom, because the side were not anchored it stayed centered to the project. You can also use the layout event of the
panel
to the contained controls resize in relation to each other, as the panel
is resized.

For my current project I have a user control with two contained

controls. One is docked to the top, the other is docked to the bottom. In the layout event, I change the height of both, so they both always take up half the space of the user control.

If you have not already seen it, the following article provides a custom layout engine for Windows Forms:

http://msdn.microsoft.com/library/de...aywinforms.asp

The following article describes the panel trick:
http://www.devx.com/dotnet/Article/6964/0/page/1

If you search google for "windows forms layout" you get a number of 'good' hits'

Hope this helps
Jay

"Richard Brown" <rb****@easylif t.org> wrote in message
news:Oe******** ******@TK2MSFTN GP10.phx.gbl...
> Ok, I celebrate and rejoice in the Anchor property. So wonderful

compared
> to the horrible 'resize' code I had to write in VB6, there is just no end
to
> the wonders of VB.NET..... uh, ok..... BUT...
>
> I have a form with a lot of controls side by side, etc. The Anchor
is > really only useful to resize 1 control on each line (and move all the > others). BUT, does anyone have any articles or other ways to do this? >
> For example, I am working on a piece of code that is similar to Anchor, and
> is an 'Extender' that allows you to specify specifc a related control, > specify your edge and its edge and then do the math from there (if that > makes sense).
>
> So, for example, the signature looks something like:
> control.Extende dAnchor(related control As Object, myedge as AnchorStyles, > relatededge as AnchorStyles)
>
> Where is is binding the specified edges of two specified controls (or the
> form).
> This is particularly useful in keeping textbox labels positioned
over > textboxes where there are multiple across.
>
> I just want to know if someone has already done this? Or has

*anything* > better than just the Anchor property?
>
>



Nov 20 '05 #7

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

Similar topics

3
12281
by: A.C. Jetter | last post by:
I am using C# in Visual Studio.Net to create an application. The problem I am having is when the main form is moved around on the screen, the "panel" form that is displayed on the tab control does not move with the main form. How can I "anchor" them so they move together? I do not want to put the panels directly on the tab control, as I want to keep them separate to allow
3
1458
by: idorjee | last post by:
Hi, Can anyone please tell me if there is a way to hyperlink to a web page which doesn't have the anchor "name" attribute (e.g., <a name="thename">), but has tags such as, <strong>. So, my question is, is it possible to hyperlink to a tag? The only way that I know is the following: <a href="http://thepage.com/example.html#thename">The Web Link</a> Thanks a lot in advance.
20
2007
by: Prisoner at War | last post by:
Hi, People, Is it possible to have an "empty" or "dummy" <a href***without*** the browser jumping back up the page?? I have a hyperlink that doesn't point to another document, but is used to call forth a modal window onClick (or is there another way, without text or image links, of calling forth JavaScript on user activity??). I would like to spare my visitors the inconvenience and visually jarring effect of getting thrown back up to...
0
9345
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
10115
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9957
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
9905
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
9775
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
6609
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
5229
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
3881
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
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.