473,394 Members | 1,699 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,394 software developers and data experts.

C# form, Control Area

Hi, I'm busy creating new GUI's and have come up against a bit of a wall. I can create my form in any shape I want using GraphicsPath and Region. However there is a set area in my forms that I want any controls to be created.

The best way I can explain this is for example, if you have a form with padding all(8) the controls on the form will fall into this inner rectange.

How can I create an area on my form that acts similar to padding?
Mar 31 '08 #1
7 1817
Plater
7,872 Expert 4TB
Can you add a Panel control to your form and anchor it about 8px from the sides on all sides?
And then like disable the form?
Mar 31 '08 #2
yeah, but I'm trying to do this in a more pure format. so that my form class doesn't have any other controls on it other than what I've created internally.

There must be a way to set like a "child client area" that all child objects on the form would fall into.
Mar 31 '08 #3
Plater
7,872 Expert 4TB
Make it an MDI parent?
Mar 31 '08 #4
Perhaps I'm not making myself clear as to what im trying to do.

Ive created a UserControl inherited from the Form.
my FormClass then has a specific shape created by settings its region to a graphics path I have created.

I've also created a whole bunch of other properties and methods to control the movement, resize etc for my FormClass.

So basically I've created a form with a specific border shape and with all the properties that I want.

however, If I create a new project and inherit Form1 from my FormClass, I can place controls anywhere I want on it. This means however that sometime a control may only be half visible on the form, because my forms shaped region cuts off some of it.

So what I want to do is set aside a specific area on the form that all chils objects will have to be placed.

I however dont want this. if i drag for create a control in the forms container I want them to be created in a specific region that is inherited of my form class.

I want it to act like a normal form. so any other developer can use it thus.
Mar 31 '08 #5
Plater
7,872 Expert 4TB
Since your usercontrol inherits from the form class, you should be able to override it's default container (.Controls is the property)
You could then do as I suggested and make a Panel that is anchored 8px (or whatever) away from the edges, then when someone calls .Controls (which would be done by the designer to add controls to your form/usercontrol), you would return the .Controls property of the Panel and not of your underlying form.
Mar 31 '08 #6
Ah, that makes sense. I'm still going to try do this without actually adding a panel, but you have definately put me on the right track. I'm going to look at overriding the OnControlAdded event, and see where it takes me.

Thanks.
Apr 1 '08 #7
Ok I sort of got what I wanted working. to do this I put in the following code:
Expand|Select|Wrap|Line Numbers
  1. public frm()
  2.         {
  3.             InitializeComponent();
  4.             this.Padding = new Padding(0, 0, 0, 0); 
  5.             //This above will then initiate the new Padding call;
  6.         }
  7.  
  8.  public new Padding Padding 
  9.         { 
  10.             get 
  11.             {
  12.                 Padding _Padding = base.Padding;
  13.                 _Padding.Top -= 20;
  14.                 return _Padding; 
  15.             }
  16.             set 
  17.             {
  18.                 value.Top += 20;
  19.                 base.Padding = new Padding(
  20. value.Left, 
  21. value.Top, 
  22. value.Right, 
  23. value.Bottom);                 
  24.             } 
  25.         }
  26.  
//-------------------------------------------------

Ok the idea here is that even when the user specifies a padding of (0,0,0,0) they will get a padding of (0,20,0,0) and although they will be able to see this on the screen, the padding will still tell them the top padding is (0).

Ideally I'll change the (20) value to the height of my title bar, and the left right and top to whatever bordering I want.

This way I dont need to create any extra controls on my form to handle my control region.

However I would still like to fiugre out a way so I can create different control regions on my form. but this will do for now.

Thanks for all the help.If I had paid a bit closer attention yesterday I might have figured it out from your first reply.
Apr 1 '08 #8

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

Similar topics

16
by: Picho | last post by:
Hi all, Is there any .NET way (I am not rulling out API usage) to add button(s) to a form's title bar? I found some non-.NET solutions that did actually work in VB6 but not in the ..NET...
3
by: ugo_lavoie | last post by:
HEy, this is normally pretty basic stuff but i dont know if i'm tired or what but right now i just can get it. Heres the problem... I have a form base on a table. 4 field : ID_Seller,...
11
by: Jozef | last post by:
I have some old code that I use from the Access 95 Developers handbook. The code works very well, with the exception that it doesn't seem to recognize wide screens, and sizes tab controls so that...
4
by: Derrick | last post by:
Hello all; I'm trying to simulate a "scrollable context menu". What I want is to have a listbox fill the entire area of a small form (with no border). Using the designer and property grid, I...
5
by: Rlrcstr | last post by:
Is there a way to darken or lighten an area of a form or control via the graphics object? I'm using an ownerdraw listbox and I want to have a small area of the item be a bit lighter than the rest...
4
by: gsb58 | last post by:
Hi! On a form I have a calendar. The form is rezised to 1024x768 (Don't worry - this is a training case) when loaded. Now I want to center the calendar on the form so that its edges are...
14
by: Galen Somerville | last post by:
My current screen resolution is set to 1024 x 768. My form size always comes up as 1032 x 748. I have tried the help sample ' Retrieve the working rectangle from the Screen class ' using the...
0
by: hmm | last post by:
Hi all I have two problems: Problem #1: I'm using a .NET Form with the property 'FormBorderStyle' set to 'None'. The idea is to completely cover the area of that Form with a UserControl. In...
9
by: Nathan Sokalski | last post by:
I am using ASP.NET 2.0's ImageMap Control to create 2 imagemaps, one directly below the other. When I do this a thin blank space appears between them. After several days of frustration I realized...
4
by: cb.brite | last post by:
Hello, I have tried this using the MouseEnter/MouseLeave events. However these events do not really refer to the rectangular shape of the form, but the client area (form area minus children...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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...
0
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...

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.