473,581 Members | 3,306 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 6646
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
12266
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...
3
1453
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...
20
1975
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...
0
7854
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...
0
7783
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...
0
8157
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...
0
6539
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...
0
5350
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...
0
3794
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...
1
2295
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
1
1394
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1119
bsmnconsultancy
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...

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.