Click here to Skip to main content
15,898,373 members
Home / Discussions / C#
   

C#

 
GeneralRe: Repositioning the cursor Pin
PIEBALDconsult30-Mar-10 14:13
mvePIEBALDconsult30-Mar-10 14:13 
GeneralRe: Repositioning the cursor Pin
skhan1730-Mar-10 14:22
skhan1730-Mar-10 14:22 
AnswerRe: Repositioning the cursor Pin
Alan N30-Mar-10 15:19
Alan N30-Mar-10 15:19 
GeneralRe: Repositioning the cursor Pin
skhan1730-Mar-10 15:38
skhan1730-Mar-10 15:38 
AnswerRe: Repositioning the cursor Pin
Som Shekhar30-Mar-10 18:38
Som Shekhar30-Mar-10 18:38 
GeneralRe: Repositioning the cursor Pin
skhan1730-Mar-10 19:47
skhan1730-Mar-10 19:47 
GeneralRe: Repositioning the cursor Pin
Som Shekhar30-Mar-10 20:01
Som Shekhar30-Mar-10 20:01 
GeneralRe: Repositioning the cursor Pin
Som Shekhar30-Mar-10 20:44
Som Shekhar30-Mar-10 20:44 
In any case, I am sure you don't believe me. So here is a code made for you. Run it and you will see it.

public class Form2 : Form
    {
        private System.ComponentModel.IContainer components = null;

        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
            this.item1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.item1ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
            this.item2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.item3ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.item4ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.subItem1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.subItem2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.menuStrip1.SuspendLayout();
            this.SuspendLayout();
            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.item1ToolStripMenuItem});
            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
            this.menuStrip1.Name = "menuStrip1";
            this.menuStrip1.Size = new System.Drawing.Size(491, 24);
            this.menuStrip1.TabIndex = 0;
            this.menuStrip1.Text = "menuStrip1";
            this.item1ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.item1ToolStripMenuItem1,
            this.item2ToolStripMenuItem,
            this.item3ToolStripMenuItem,
            this.item4ToolStripMenuItem});
            this.item1ToolStripMenuItem.Name = "item1ToolStripMenuItem";
            this.item1ToolStripMenuItem.Size = new System.Drawing.Size(77, 20);
            this.item1ToolStripMenuItem.Text = "MainMenu";
            this.item1ToolStripMenuItem.MouseMove += new System.Windows.Forms.MouseEventHandler(this.item1ToolStripMenuItem_MouseMove);
            this.item1ToolStripMenuItem1.Name = "item1ToolStripMenuItem1";
            this.item1ToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
            this.item1ToolStripMenuItem1.Text = "Item 1";
            this.item2ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.subItem1ToolStripMenuItem,
            this.subItem2ToolStripMenuItem});
            this.item2ToolStripMenuItem.Name = "item2ToolStripMenuItem";
            this.item2ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
            this.item2ToolStripMenuItem.Text = "Item 2";
            this.item3ToolStripMenuItem.Name = "item3ToolStripMenuItem";
            this.item3ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
            this.item3ToolStripMenuItem.Text = "Item 3";
            this.item4ToolStripMenuItem.Name = "item4ToolStripMenuItem";
            this.item4ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
            this.item4ToolStripMenuItem.Text = "Item 4";
            this.subItem1ToolStripMenuItem.Name = "subItem1ToolStripMenuItem";
            this.subItem1ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
            this.subItem1ToolStripMenuItem.Text = "SubItem1";
            this.subItem2ToolStripMenuItem.Name = "subItem2ToolStripMenuItem";
            this.subItem2ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
            this.subItem2ToolStripMenuItem.Text = "SubItem2";
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(491, 388);
            this.Controls.Add(this.menuStrip1);
            this.MainMenuStrip = this.menuStrip1;
            this.Name = "Form2";
            this.Text = "Form2";
            this.menuStrip1.ResumeLayout(false);
            this.menuStrip1.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();
        }

        private System.Windows.Forms.MenuStrip menuStrip1;
        private System.Windows.Forms.ToolStripMenuItem item1ToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem item1ToolStripMenuItem1;
        private System.Windows.Forms.ToolStripMenuItem item2ToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem subItem1ToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem subItem2ToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem item3ToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem item4ToolStripMenuItem;

        public Form2()
        {
            InitializeComponent();
            SetMenuDetails(item1ToolStripMenuItem);
        }

        private void SetMenuDetails(ToolStripMenuItem menu)
        {
            foreach (ToolStripMenuItem item in menu.DropDownItems)
            {
                UpdateItem(item);
            }
        }

        private void UpdateItem(ToolStripMenuItem item)
        {
            foreach (ToolStripMenuItem subItem in item.DropDownItems)
            {
                UpdateItem(subItem);
            }

            item.MouseMove += new MouseEventHandler(item_MouseUp);
        }

        void item_MouseUp(object sender, MouseEventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;
            if (item.DropDownItems.Count > 0)
            {
                ToolStripMenuItem subItem = (ToolStripMenuItem)item.DropDownItems[0];
                item.ShowDropDown();
                Point location = subItem.Bounds.Location;
                Cursor.Position = new Point(Cursor.Position.X + location.X + item.Bounds.Width/2, Cursor.Position.Y + location.Y );
            }
        }

        private void item1ToolStripMenuItem_MouseMove(object sender, MouseEventArgs e)
        {
            this.Text = e.Location.ToString();
        }
    }

Questioncustom control properties Pin
xilefxilef30-Mar-10 10:13
xilefxilef30-Mar-10 10:13 
AnswerRe: custom control properties Pin
Paw Jershauge30-Mar-10 12:52
Paw Jershauge30-Mar-10 12:52 
GeneralRe: custom control properties Pin
xilefxilef30-Mar-10 13:18
xilefxilef30-Mar-10 13:18 
AnswerRe: custom control properties Pin
Paw Jershauge30-Mar-10 13:31
Paw Jershauge30-Mar-10 13:31 
GeneralRe: custom control properties Pin
yu-jian1-Apr-10 17:04
yu-jian1-Apr-10 17:04 
QuestionQuestion about the Type object Pin
Richard Blythe30-Mar-10 8:22
Richard Blythe30-Mar-10 8:22 
AnswerRe: Question about the Type object Pin
OriginalGriff30-Mar-10 8:29
mveOriginalGriff30-Mar-10 8:29 
GeneralRe: Question about the Type object Pin
PIEBALDconsult30-Mar-10 9:14
mvePIEBALDconsult30-Mar-10 9:14 
GeneralRe: Question about the Type object Pin
OriginalGriff30-Mar-10 9:22
mveOriginalGriff30-Mar-10 9:22 
GeneralRe: Question about the Type object Pin
PIEBALDconsult30-Mar-10 9:41
mvePIEBALDconsult30-Mar-10 9:41 
AnswerRe: Question about the Type object Pin
Luc Pattyn30-Mar-10 9:00
sitebuilderLuc Pattyn30-Mar-10 9:00 
GeneralRe: Question about the Type object Pin
PIEBALDconsult30-Mar-10 9:17
mvePIEBALDconsult30-Mar-10 9:17 
GeneralRe: Question about the Type object Pin
Richard Blythe30-Mar-10 9:23
Richard Blythe30-Mar-10 9:23 
GeneralRe: Question about the Type object Pin
Luc Pattyn30-Mar-10 9:28
sitebuilderLuc Pattyn30-Mar-10 9:28 
GeneralRe: Question about the Type object Pin
Richard Blythe30-Mar-10 9:33
Richard Blythe30-Mar-10 9:33 
GeneralRe: Question about the Type object Pin
Luc Pattyn30-Mar-10 9:35
sitebuilderLuc Pattyn30-Mar-10 9:35 
AnswerRe: Question about the Type object [modified] Pin
PIEBALDconsult30-Mar-10 9:02
mvePIEBALDconsult30-Mar-10 9:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.