473,387 Members | 1,592 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Auto Resizing Form

SammyB
807 Expert 512MB
I have a form with a ToolStrip at the top and a TabControl just below it. The TabControl fills the rest of the form and has it's tabs on the right, off of the form. The click event of the ToolStripButtons selects the correct tab. Each tab page has a TableLayoutPanel that is fill-docked and contains the controls. As part of the tool strip button click event, I would like to change the height of the form to remove any empty space at the bottom of the form. Right now, I just have the height for each page hard coded, but I would like to iterate thru the current TableLayoutPanel.Controls, find the bottom-most control, and use that control's Bottom property to set the form height.

I can do all of that except setting the height correctly, because the bottom-most control location is relative to the TableLayout panel. How can I translate this into a form location? TIA --Sam
Jan 6 '09 #1
4 2298
Plater
7,872 Expert 4TB
Before the height thing, you say you just made your tabcontrol be large enough to shove its tabs off to the side so they are not visible? You can just turn them off with a property.

Ok, so you want to size of the overall form to change depending on which Tab is currently visible? So if there are a lof of controls on a page (top - to - bottom) you want that the height of the form be increased, versus a tab with very few controls getting the form shrunk?

Can you get away with just using anchors on your controls? And you don't want to go by how big you "know" the controls are, but to do it automatically?

I am confused.
Jan 7 '09 #2
SammyB
807 Expert 512MB
@Plater
What property? I assume it must be a framework 3.0 property. Unfortunately, I am still using framework 2.0. However, if there is one in 2.0, please let me know ASAP. It is my biggest need.

@Plater
Sorry, I included too many non-pertinent details. Let me start over:
I have a complicated form with several layers of container controls. If I have a control on the form, then the Location property is relative to the parent container control. Is there an easy way to determine the location of this control relative to the form. For example, if I place a group box on a form at location (10,10) and place a label in the group box at location (5,5), then the label’s Location property is (5,5), but I would like a function that returns (15,15), the location of the control on the form.
Jan 7 '09 #3
Plater
7,872 Expert 4TB
No, it would have been for framework 2.0 since that is what I use as well. Cannot for the life of me find it now. BUT I did find the Appearence property which turned the tabs into buttons, which gave the appearance of a toolstrip above (since that was where i had the tabs aligned to) which could also be of help? I saw ItemSize, which sets how big the tab is, but it wouldn't let me set it to zero, just (1,1)

You could maybe make a function that take a control and goes upwards through its parent adding up the values of the location?

Like:
Expand|Select|Wrap|Line Numbers
  1. Point GetLocationOfCRelativeToP(Control C, Control P)
  2. {
  3. }
  4.  
And work from C upwards to P (or until no more parents)


There is a PointToScreen() function that could maybe be used to skip those steps. Get the Point location on the screen of the form and then for the control and compute the diference? That would rely on them both being visible on screen though I think
Jan 7 '09 #4
SammyB
807 Expert 512MB
@Plater
Tried that, but I like the toolstrip better

@Plater
This is perfect! I set the Dock to Fill, Alignment to Right, SizeMode to Fixed, and ItemSize to (15,15). This allows me to switch tabs in the design mode. Then, in the FormLoad event, I set the ItemSize to (0,1). Presto, no tabs! Thanks!

@Plater
That's what I should have done! But, I already have one working that goes upward thru the containers like your first solution.

Thanks again for all of your help! --Sam
Jan 7 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: TJ Talluto | last post by:
<facts> I have a "month calendar" that always displays exactly 42 days... and alongside is a vertical box that displays the detail (form fields) of any particular select event that appears on the...
1
by: Terry | last post by:
I've seen several posts from people who have seen this flashing in TreeView's when resizing a form. I've noticed it in my app, but only in the child windows. For example, my main form has a...
12
by: Søren Reinke | last post by:
Hi there I have a little problem. How do i make sure that a graph is not redrawn while the form with the graph is being resized ? I have tried to add a mouse up/down event handler on the...
11
by: Sharon | last post by:
I'm writing a new control derived from UserControl. I need to get an event when the control is done resizing. I tried the Resize, SizeChanged, Move and the Layout events and I also tried to...
0
by: 23s | last post by:
Is there any way I can send a vertical value to a form's scroll position? I have a full-screen form that, at launch, contains an empty tab sheet. At run time, the user can dynamically append a...
1
by: seymourowl | last post by:
What im wanting to do is have a code for auto resizing a browser so that it automatically detects whether a screen is 1024x768, 800x600, or whatever. I want this so that my webpage is always centered...
6
by: JDeats | last post by:
I have a WinForms based application written for the .NET Framework 2.0 and in this application I need to be able to be able to take some action in code when the user finishes resizing the form. ...
10
by: mishrarajesh44 | last post by:
hii all, I am facing a problem currently.. i have a script for image uploading and resizing.. the image uploading takes place properly for every size images.. but, the resizing works for...
3
by: jkwok | last post by:
Hi, I have a form with two rich text boxes and two buttons. Some of the users want to be able to maximize and/or resize the form and have the rich text boxes resize to fit and the buttons always...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...

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.