473,668 Members | 2,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

position of controls on the form

153 New Member
I am making one form by hand (without vs 2005).
i am positioning the menustrip above the toolstrip but still bue to some reason the menu strip is below it.

I inseted breakpoint and when the code goes through this
the data is
MainMenu.Locati on = {X = 0 Y = 25}
OneToolStrip.Lo cation = {X = 0 Y = 0}

why is this happening ?

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Windows.Forms;
  5.  
  6. namespace Consolepractice
  7. {
  8.     class MyForm : Form
  9.     {
  10.         MenuStrip MainMenu;
  11.  
  12.         ToolStripMenuItem MainMenuItemfile;
  13.         ToolStripMenuItem Itemsave;
  14.         ToolStripMenuItem ItemSaveAs;
  15.  
  16.         ToolStripMenuItem MainMenuItemEdit;
  17.  
  18.         ContextMenuStrip MainContextMenu;
  19.         ToolStripMenuItem MainContextMenuCopy;
  20.         ToolStripMenuItem MainContextMenuItemCut;
  21.         ToolStripMenuItem MainContextMenuItemPaste;
  22.  
  23.         Button OneButton;
  24.  
  25.         ToolStrip OneToolStrip;
  26.         ToolStripButton OneTSButton;
  27.         public MyForm()
  28.         {
  29.             initialisecomponents();
  30.             Application.EnableVisualStyles();
  31.         }
  32.  
  33.         void initialisecomponents()
  34.         {
  35.             MainMenu = new MenuStrip();
  36.                 MainMenuItemfile = new ToolStripMenuItem();
  37.                     Itemsave = new ToolStripMenuItem();
  38.                     ItemSaveAs = new ToolStripMenuItem();
  39.                 MainMenuItemEdit = new ToolStripMenuItem();
  40.             MainContextMenu = new ContextMenuStrip();
  41.                 MainContextMenuItemCut = new ToolStripMenuItem();
  42.                 MainContextMenuCopy = new ToolStripMenuItem();
  43.                 MainContextMenuItemPaste = new ToolStripMenuItem();
  44.  
  45.             OneButton = new Button();
  46.  
  47.             OneToolStrip = new ToolStrip();
  48.             OneTSButton = new ToolStripButton();
  49.  
  50.  
  51.             this.MainMenuStrip = MainMenu;
  52.             this.Text = "Hand made form !";
  53.             this.Text = "Main menu:" + MainMenu.Location.ToString() + " toolstrip" + OneToolStrip.Location.ToString();
  54.             this.ContextMenuStrip = MainContextMenu;
  55.             //this.Controls.Add(ContextMenu); (Dont need to "add" a contextmenu !)
  56.             this.Controls.Add(MainMenu);
  57.             this.Controls.Add(OneButton);
  58.             this.Controls.Add(OneToolStrip);
  59.  
  60.             MainMenuItemfile.Text = "File";
  61.             MainMenuItemfile.Size= new System.Drawing.Size(152, 22);
  62.             MainMenuItemfile.DropDownItems.Add(Itemsave);
  63.             MainMenuItemfile.DropDownItems.Add(ItemSaveAs);
  64.  
  65.                 Itemsave.Text = "Save";
  66.                 Itemsave.Size = new System.Drawing.Size(152, 22); ;
  67.  
  68.                 ItemSaveAs.Text = "Save as";
  69.                 ItemSaveAs.Size = new System.Drawing.Size(152, 22);
  70.  
  71.             MainMenuItemEdit.Text = "Edit";
  72.             MainMenuItemEdit.Size = new System.Drawing.Size(152, 22);
  73.  
  74.             MainContextMenu.Size = new System.Drawing.Size(114, 26);
  75.             MainContextMenu.Items.Add(MainContextMenuItemCut);
  76.             MainContextMenu.Items.Add(MainContextMenuCopy);
  77.             MainContextMenu.Items.Add(MainContextMenuItemPaste);
  78.  
  79.             MainContextMenuCopy.Size = new System.Drawing.Size(113, 22);
  80.             MainContextMenuCopy.Text = "Copy";
  81.  
  82.             MainContextMenuItemCut.Size = new System.Drawing.Size(113, 22);
  83.             MainContextMenuItemCut.Text = "Cut";
  84.  
  85.             MainContextMenuItemPaste.Size = new System.Drawing.Size(113, 22);
  86.             MainContextMenuItemPaste.Text = "Paste";
  87.  
  88.             MainMenu.Items.Add(MainMenuItemfile);
  89.             MainMenu.Items.Add(MainMenuItemEdit);
  90.             MainMenu.Location = new System.Drawing.Point(0, 0);
  91.  
  92.             OneButton.Text = "Click me !";
  93.             OneButton.Size = new System.Drawing.Size(75, 23);
  94.             OneButton.Location = new System.Drawing.Point(10,0);
  95.  
  96.             OneToolStrip.Items.Add(OneTSButton);
  97.             OneToolStrip.Text = "Hey !";
  98.             OneToolStrip.Location = new System.Drawing.Point(0, 55);
  99.  
  100.             OneTSButton.Text = "Click me too !";
  101.  
  102.  
  103.         }
  104.     }
  105.  
  106.     class Program
  107.     {
  108.         static void Main(string[] args)
  109.         {
  110.             MyForm frm = new MyForm();
  111.             Application.Run(frm);
  112.         }
  113.     }
  114. }
Dec 4 '08 #1
7 3864
akshaycjoshi
153 New Member
Now i have added two buttons one of which increases the postion of menustrip and other of toolstrip.

But these buttons fail to change their location !
it seems as if they come down but again go to original position.
Dec 4 '08 #2
Plater
7,872 Recognized Expert Expert
Well a menu strip by definition is "docked" to its parent control I believe.
Try putting it in a panel and then moving the panel around?
Dec 4 '08 #3
akshaycjoshi
153 New Member
I dont want to move anything.
I just want to have menustrip at top and below it the toolstrip.
How to do that ?
Dec 5 '08 #4
UdayKumarB
5 New Member
Hi Akshay,

Every control will have bring to front property try that may be it will work.

Uday
Dec 5 '08 #5
akshaycjoshi
153 New Member
I am asking why the menustrip is not positioned at the top ?
Where am i wrong ?
Dec 5 '08 #6
Plater
7,872 Recognized Expert Expert
You have a lot of positioning out of whack in there. Your regular button covers your tooltip button.
You know you can use the designer to place everything where you want it, then open the designer code and see how they did it.

The menu strip IS at the top, its just covered by the toolstrip.
Just put in this:
OneToolStrip.Do ck = DockStyle.None;
Dec 5 '08 #7
vekipeki
229 Recognized Expert New Member
Oops, I made a mistake, never mind.
Dec 24 '08 #8

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

Similar topics

1
2381
by: cindy | last post by:
I have a web form I checked body tag it is <body ms_positioning="FlowLayout"> I load a user control on form, all the textboxes position like they are in grid layout I cannot drag them. What am i missing I am doing something really dumb please help me. -- cindy mello
3
2708
by: John Spiegel | last post by:
Hi all, How can you control where a placeholder is positioned on a Web Form? AFAIK, It doesn't seem to support a style or other positioning (or even sizing) attributes. TIA, John
1
1496
by: Martin Eyles | last post by:
I am trying to put web controls in my page which inherit their position from style property. So far I have the following code, but the "hello"s don't appear in their desired position. Has anyone any idea how to fix this? Thanks, ME TestPositionInheritance.aspx -----------------------------------
1
1777
by: Rob R. Ainscough | last post by:
I'm at a new level of frustration just trying to get my controls to line up and stay in place. I'm using a MultiView containing 4 views - some views have Panels. I can't use absolution position on my controls because in MultiView that means when the views are switched (ActiveViewIndex) the controls in the new view are absolution position which means they are displayed lower down the page (where they were arranged in the original view...
5
1740
by: sagar | last post by:
is there any way to find the position of mouse click on a form actually the problem is i m having more than one controls on a form i want to find which control is selected using mouse down any help is fine for me thanks
4
1142
by: Marc | last post by:
Hi, In order to save user preferences I need to grab the name and position of all buttons on a form, which i will then save to a text file. Anyone know how I can easily get this information? Thanks Marc
1
2629
by: Alan T | last post by:
I just put 2 text boxes on a web form but they are side by side, I have no way to reposition them.
3
55956
by: Andrew Hall | last post by:
Hi all Can anyone advise how to get the position of an open form and how to set the position of an opening form within the access window. I have: MA Access97 (because I do not have the funds to obtain a more recent version nor the time to learn the new interface) Form1 and form2. Both forms are an identical size because of the length of the captions of the controls on the forms.
3
1977
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi, How can I move a wizardstep dynamacally form one position to another. eg: change the position of step 1 to be step 4. thanks. -- Regards,
3
3409
by: Dan | last post by:
Hi, I made a form consisting of a lot of server-controls (dropdownlist, radiobuttonlist ...). Some controls have their property 'autoPostBack' = true because some things must happen when selectedvalue is changed. My problem: suppose that the property 'autoPostBack' of 20th control is true, each time the user changes the selectedvalue, he is sent back to the top of the form after postback. He has then to scroll down to find the 21th...
0
8459
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8890
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
8791
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...
0
8653
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
7398
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4376
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2786
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
2
2018
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1783
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.